In my page, the datepicker dateFormat option is being set automatically by loading a localized .js file according to the current users's language settings. Elsewhere in the page, I need to format some dates, so I'd like to get the dateFormat option back out of the datePicker.
The jQuery documentation says you can retrieve the dateFormat option like so:
$('.selector').datepicker('option', 'dateFormat');
However, this returns a jQuery object wrapping the datePicker, not a string value as expected. Is this a bug? Is there another way to retrieve the dateValue option?
I'm using jQuery 1.3.2 and jQuery UI 1.7.1.
I know that I could simply look up the dateFormat another way, but pulling it out of the datepicker would be clean and elegant.
inside the jQuery script code just paste the code. $( ". selector" ). datepicker({ dateFormat: 'yy-mm-dd' });
Do one of the following: For a text box control or a date picker control, ensure that the Data type list displays the appropriate data type, and then click Format. For an expression box control, ensure that the Format as list displays the appropriate data type, and then click Format.
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.
Using that method works for me1. Are there multiple items with the selector class? Do you know that the element has already been added as a date picker?
javascript:alert($("#datepicker").datepicker('option', 'dateFormat'));
into the address bar, and it will give you "mm/dd/yy."
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