With the jQuery datepicker, how does one change the year range that is displayed? On the jQuery UI site it says the default is "10 years before and after the current year are shown". I want to use this for a birthday selection and 10 years before today is no good. Can this be done with the jQuery datepicker or will I have to use a different solution?
link to datepicker demo: http://jqueryui.com/demos/datepicker/#dropdown-month-year
I will suggest to add formate on datepicker as "YYYY" so it will only show years inside it.
There's a changeYear property on the datepicker that you can set to true . This will render a select list from which you can choose the year you'd like. Save this answer.
A date-picker of jQuery UI is used to provide a calendar to the user to select the date from a Calendar. This date picker usually connected to a text-box so user selection of date from the calendar can be transferred to the textbox.
If you look down the demo page a bit, you'll see a "Restricting Datepicker" section. Use the dropdown to specify the "Year dropdown shows last 20 years
" demo , and hit view source:
$("#restricting").datepicker({ yearRange: "-20:+0", // this is the option you're looking for showOn: "both", buttonImage: "templates/images/calendar.gif", buttonImageOnly: true });
You'll want to do the same (obviously changing -20
to -100
or something).
Why not show the year or month selection boxes?
$( ".datefield" ).datepicker({ changeMonth: true, changeYear: true, yearRange:'-90:+0' });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With