Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 327
0plus1 Avatar asked Nov 14 '11 10:11

0plus1


1 Answers

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.

like image 180
Frédéric Hamidi Avatar answered Oct 09 '22 21:10

Frédéric Hamidi