I am using the datepicker jquery plugin with the settings below.
$("#date").datepicker({
showButtonPanel: true,
changeMonth: true,
changeYear: true,
showOtherMonths: true,
selectOtherMonths: true
});
Now what i want to do is allowing the user to set the year. I mean by manual changing the input of the selection drop down.
Is there any setting to do that ?
The reason I would like to do that is because I don't know, if the user is selecting a date from the year 1920 or 2220 or what ever year. So I don't have a good default date value. And the dropdown interface isn't that userfriendly if you have to click 20 times to get from the year 2000 to the year 1600.
Edit: What I want to do is the "Show unlimited years:" from keith-wood.name/datepick.html#monthyear. Is there anything similar with the standard jquery datepicker. I can't find the setting yearRange: 'any' in the jquery datepicker documentation.
Here's one specific for your code: var date = $('#datepicker'). datepicker({ dateFormat: 'dd-mm-yy' }). val();
By default, the date format of the jQuery UI Datepicker is the US format mm/dd/yy, but we can set it to a custom display format, eg: for European dates dd-mm-yyyy and so on. The solution is to use the date picker dateFormat option.
If you like to restrict access of users to select a date within a range then there is minDate and maxDate options are available in jQuery UI. Using this you can set the date range of the Datepicker. After defining these options the other days will be disabled which are not in a defined range.
jQuery("#date").datepicker({
dateFormat: "dd-mm-yy",
changeMonth: true,
changeYear: true,
yearRange: "-80:+00" // Use this to get the list of years you more than default range.
});
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