I have a textfield called:”deadline”, which is have the value,like this:
<input type="input" maxlength=10 value="2011-09-14" id="deadline" name="deadline" class="date_picker"></input>
But when I ran this js, it is gone, I can’t see the value:
$('.date_picker').datepicker();
$('.date_picker').datepicker('option', 'dateFormat', 'yy-mm-dd', 'showOn', '');
Why the date_picker disappear my value? If I want it back,how can I do so? Thanks.
The Date Picker will typically clear your HTML given default value depending on your formatting options. It does, however, have an option for setting the Default Date:
http://jqueryui.com/demos/datepicker/#option-defaultDate
Important Note: Make sure you Default Value matches the format of your dateFormat
So, add to your options the dateFormat with either a string of your value or a JavaScript date object. More information:
Finally, if you continue to have problems, your options string might be malformed. I haven’t seen an options string implemented like that, but that doesn’t mean it doesn’t work. If you still have issues, try implementing your options in a similar format to this: