Setting Year Range Dropdown in jQuery UI Datepicker

By default, jQuery UI Datepicker’s year dropdown shows only 10 years. It is alright if we are using Datepicker to select recent date, but what if user needs to go way back (like 50 years)? This will create a big inconvenience if we are using jQuery UI Datepicker for birthdate.

The solution is to add yearRange option when initializing jQuery UI Datepicker. This will extend the amount of years generated on the dropdown.

See the full snippet below:

 

1 comments On Setting Year Range Dropdown in jQuery UI Datepicker

Leave a reply:

Your email address will not be published.