I have a page where I keep track of various dates. So I end up using datepicker through jquery anywhere from 10-200 times. I want to set the default for all cases of datepicker to the 'yy-mm-dd' - but I can't seem to figure out how to set that?
I have a page where I keep track of various dates. So I end up using datepicker through jquery anywhere from 10-200 times. I want to set the default for all cases of datepicker to the 'yy-mm-dd' - but I can't seem to figure out how to set that?
Share Improve this question asked Feb 22, 2012 at 19:01 Sol OrwellSol Orwell 1151 gold badge3 silver badges9 bronze badges2 Answers
Reset to default 26I end up using datepicker through jquery anywhere from 10-200 times.
I'm assuming you're calling datepicker()
separately for each input, probably by id
. There's no need for that.
Use a class
as a hook on your input:
<input class="my-datepicker">
Then call datepicker
on elements with that class with your default configuration:
$('.my-datepicker').datepicker({
dateFormat: 'yy-mm-dd'
});
When you need a different configuration, use/assign a different class name.
You can also use setDefaults
(probably what you're looking for):
$.datepicker.setDefaults({
dateFormat: 'yy-mm-dd'
});
Go to the file jquery.ui.datepicker.js
.
function Datepicker()
{
dateFormat: 'mm/dd/yy'
}
Change it to the format you prefer. It will change the format for your whole website.