Search code examples
javascriptjquerydatepickerjquery-ui-datepicker

Jquery datepicker, select year


I would like to have more than 11 dates to choose from, instead I'd like to have all possible years in one single dropdown

This is my code:

$( function() {
    $( "#data" ).datepicker({
        changeMonth: true,
        changeYear: true,
        minDate: "-100Y",
        maxDate: "-18Y"
    });
} );

I would like to have full selection from 1917 to 1999

date picker


Solution

  • Try this :

    $(function() {
      $("#data").datepicker({
        changeMonth: true,
        changeYear: true,
        yearRange: "-100:-18"
      });
    });
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
    <input type="text" id="data" />