I've found a very easy to use datepicker called jquery datepicker. But the problem is when I want to use it for birth date. For example: my birth year is 1986 and the current year is 2013, then I need to click left arrow many times to decrease the months until I find 1986. It will be more troublesome if my birth year is 1960 or below.
Does anybody know any datepicker plugin that suitable for this? Perhaps a datepicker which year or month can be selected from dropbox or something?
In short: you may do that bythe Restricting Datepicker section in the demo page.
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).
Option # 2: is using the changeMonth
and changeYear
options of the api.
Try using 'yy' for the current year like:
$('.datepicker').datepicker({changeYear: true, yearRange : 'yy-50:yy+1'});
for more information view http://api.jqueryui.com/datepicker/#option-yearRange
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