On a recent development I wanted to use the jQuery UI datepicker to allow users to select their dob. With the standard implementation the user is required to use the forward and back arrows to switch through the available months.
With a date of birth picker I want the user to be able to select the year and month with minimum clicks. Using the changeYear and Change Month options this will make them both a drop down list.
$(".datepicker").datepicker({
dateFormat: 'dd/mm/yy',
changeYear : 'true',
changeMonth: 'true'
});
As standard the datepicker only goes back 10 years so we also need to update this using the yearRange option.
$(".datepicker").datepicker({
dateFormat: 'dd/mm/yy',
changeYear : 'true',
changeMonth: 'true',
yearRange: "-90:+0"
});
That's it the options required for a dob picker going back 90 years.
Posted on
Mon, May 16, 2011
by John Walker
filed under