Skip to main content

How to Use Bootstrap datepicker

How to Use Bootstrap datepicker

bootstrap provides simple and attractive datepicker widget that we can use in html page wihtout any problem
 to use bootstrap datepicker with html or php we need to call cdn datepicekr js.

INDEX.HTML
 <div class="container-fluid">
  <div class="row">
   <div class="col-md-6 col-sm-6 col-xs-12">

    <!-- Form code begins -->
    <form method="post">
      <div class="form-group"> <!-- Date input -->
        <label class="control-label" for="date">Date</label>
        <input class="form-control" id="date" name="date" placeholder="MM/DD/YYY" type="text"/>
      </div>
      <div class="form-group"> <!-- Submit button -->
        <button class="btn btn-primary " name="submit" type="submit">Submit</button>
      </div>
     </form>
     <!-- Form code ends -->

    </div>
  </div>  
 </div>
</div


JS TO ADD DATEPCIKER
<!-- Include jQuery -->
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.3.min.js"></script>

<!-- Include Date Range Picker  -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.4.1/js/bootstrap-datepicker.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.4.1/css/bootstrap-datepicker3.css"/>


You can use bootstrap datepicker with simple jqueyr code
 <script>
  $(function() {
    $(".datepicker").datepicker({
          dateFormat: "yy-mm-dd",
         minDate: 0
    });

 
  });
</script>

But if you want more options then you can use this jQuery Code

<script>

    $(document).ready(function(){
      var date_input=$('.datepicker'); //our date input has the name "date"
      var options={
        setDate: new Date(),
        format: 'yyyy-mm-dd',
        todayHighlight: true,
        autoclose: true,
        startDate: new Date() // To set start date of datepicker
      };
      date_input.datepicker(options);
    })

</script>

Other Options of Bootstrap datepicker
1. autoclose -> Close datepicker after date select
2. beforeShowDay =>   use this function to enable or disable specific day by returning true or false.
3. beforeShowMonth ->
4. beforeShowYear ->
5. beforeShowDecade ->
6. beforeShowCentury ->
7. calendarWeeks ->
8. clearBtn -> displays a “Clear” button at the bottom of the datepicker
9. container -> Appends the date picker popup to a specific element; eg: container: ‘#picker-container’
10. datesDisabled  ->  Disable the Array of date strings or a single date string.
11. daysOfWeekDisabled -> Days of the week that should be disabled.
12. daysOfWeekHighlighted -> Days of the week that should be highlighte
13. defaultViewDate -> Date to view when initially opening the calendar
14. disableTouchKeyboard -> If true, no keyboard will show on mobile devices
15. enableOnReadonly -> (TRUE OR FALSE) and if boolean value is true then the datepicker will not show on a readonly datepicker field.
16. endDate -> Set Max date
17. forceParse ->
18. assumeNearbyYear ->
19. format -> Set The date format
20. immediateUpdates ->
21. inputs ->
22. keepEmptyValues -> Only effective in a range picker
23. keyboardNavigation -> not allow date navigation by arrow keys
24. language -> The IETF code (eg “en” for English, “pt-BR” for Brazilian Portuguese) of the language to use for month and day names.
25. maxViewMode -> Set a max limit for the view mode.
26. minViewMode -> Set a minimum limit for the view mode.
27. multidate -> Enable multidate picking.
28. multidateSeparator -> Separate the multidates
29. orientation ->  Set the location of the picker popup’s
30. showOnFocus -> the datepicker show on focus
31. startDate   -> Set minDate of datepicker
32. startView  ->  Useful for date-of-birth datepickers.
33. templates -> Set template or use styles in datepicker
34. title -> Set the Title of datepicker
35. todayBtn -> displays a “Today” button at the bottom of the datepicker to select the current date
36. todayHighlight -> highlights the current date
37. toggleActive -> selecting the currently active date in the datepicker will unset the respective date.
38. weekStart -> Day of the week start.
39. zIndexOffset  -> Set z-index css of bootstrap datepicker

So thats all options of  bootstrap datepicker.





Related Posts-

Tutorial -  How to use Bootstrap Datepicker
Bootstrap datepicker with input field
How to set minDate in Bootstrap datepicker
All options of bootstrap datepicker

Comments

Popular posts from this blog

Run and compile sass scss file to css using node

  Today we learn how to use scss and generate css using node  or Run and compile sass scss file to css using node   So please follow simple  steps :-   Today we will create a project that can read scss file and generates css with it  Note: Make sure you have installed node in your system. If you want to help to install node js based on your system then check our other tutorial or check node js official website. Now create a blank folder and open  terminal(linux) or cmd(windows) and navigate to your current project folder by using cd command Now run below command npm init after enter it will ask you some package info that you can fill according to you or just keep enter until it finished. The above command will generate package.json file Now  we will install npm module that will convert our scss to css Run below command: npm install node-sass So we have installed node-sass package . Now open package.json file in your...

How to retrieve Facebook Likes, share , comment Counts

function facebook_count($url){     // Query in FQL     $fql  = "SELECT share_count, like_count, comment_count ";     $fql .= " FROM link_stat WHERE url = '$url'";     $fqlURL = "https://api.facebook.com/method/fql.query?format=json&query=" . urlencode($fql);     // Facebook Response is in JSON     $response = file_get_contents($fqlURL);     return json_decode($response); } $fb = facebook_count('https://www.facebook.com/BahutHoGyiPadhai'); // facebook share count echo $fb[0]->share_count;  echo "like"; // facebook like count echo $fb[0]->like_count ; echo "comment"; // facebook comment count echo $fb[0]->comment_count;  ?>

Solution-windows 'expo' is not recognized as an internal or external command

Solution for expo is not recognized as an internal or external command,operable program or batch file in Windows 10 Sometimes expo will not work globally mostly in windows 10, If you are facing same issue then follow the below Steps 1) Click on windows button and search for  " Environment variables"  and click on "Edit the system environment variables" 2) Now you will see a popup like below screen. Then you need to click on Environment Variables. (Please see highlight part in below image)     3)Then click on new button that i have highlighted in below image 4. Then a popup will open and you need to fill details like below mentioned Variable Name :Path Variable Value: %USERPROFILE%\AppData\Roaming\npm Here we are creating a new path variable and passing location of npm.   Now Click on OK and close all the terminal windows and open new CMD or terminal and type Expo . Great now you can access expo from any...