jquery ui datepicker. How can I show ALL of the possible years (for the birthdate)?

0plus1 picture 0plus1 · Nov 14, 2011 · Viewed 7.2k times · Source

I'm using jquery ui datepicker with changeYear. The problem is that it shows the years in chunks (from 1985 to 2005, then clicking on 1985 opens other years) I need to show ALL the years in the range I'm passing like this:

$(".datepickerBDAY_trigger").datepicker({
    "dateFormat": "yy-mm-dd",
    changeMonth: true,
    changeYear: true,
    maxDate: "-16Y",
    minDate: "-100Y"
});

How can I do this? I cannot find this information anywhere else.

Thanks

Answer

Frédéric Hamidi picture Frédéric Hamidi · Nov 14, 2011

You can use the yearRange option. Its first form (-nn:+nn) allows you to specify a range relative to the current year instead of the currently selected year.

$(".datepickerBDAY_trigger").datepicker({
    dateFormat: "yy-mm-dd",
    changeMonth: true,
    changeYear: true,
    maxDate: "-16Y",
    minDate: "-100Y",
    yearRange: "-100:-16"
});

You can see the results in this fiddle.