Bootstrap year picker example using datepicker js plugin

Bootstrap year picker example using datepicker js plugin

Bootstrap year picker example using datepicker js plugin

In this tutorial, you will know how to use year picker in your form using Bootstrap datepicker plugin.

In my last post, i told you about datepicker js plugin which is a simple jquery blugin built with bootstrap-datepicker.js to add flexible datepicker field to your form.

There are various option available with datepicker.

You need to pass extra option minViewMode with datepicker method that is used to set minimum limit for the view mode.

To get year picker you can set value of minViewMode either string 'years' or number value 2.

If you need to get month picker by year you need to use minViewMode:1 with format: 'mm-yyyy'.

See the given example :

  1. <html>
  2. <head>
  3. <title>Bootstrap year picker example using datepicker js plugin</title>
  4. <link href="" rel="stylesheet">
  5. <link href="" rel="stylesheet">
  6. <script src=""></script>
  7. <script src=""></script>
  8. <script src=""></script> </head>
  9. </head>
  10. <body>
  11. <strong>Year Picker :</strong> <input class="form-control" type="text" placeholder="click to show datepicker" id="example1">
  12. <script type="text/javascript">
  13. // When the document is ready
  14. $(document).ready(function () {
  15. $('#example1').datepicker({
  16. minViewMode: 'years',
  17. autoclose: true,
  18.             format: 'yyyy'
  19. });
  20. });
  21. </script>
  22. </body>
  23. </html>

To get month picker use following script :

  1. $(document).ready(function () {
  2. $('#example1').datepicker({
  3. minViewMode: 1,
  4. autoclose: true,
  5. format: 'mm-yyyy'
  6. });
  7. });
Bootstrap datepicker example text input with specifying date format

Phone: (+91) 8800417876
Noida, 201301
sakarya escort sakarya escort bayan sakarya escort serdivan escort sakarya escort sakarya escort serdivan escort
karasu escort akyazı escort serdivan escort akyazı escort ferizli escort sapanca escort serdivan escort söğütlü escort sakarya escort izmit escort arifiye escort erenler escort hendek escort kocaali escort pamukova escort taraklı escort geyve escort