When binding datepicker:
$('#schedule').datepicker();
it will use the default dateFormat
and this is "mm/dd/yy"
; your "15-May-2012"
does not conform to this format, so the datepicker clears it when it cannot parse it using "mm/dd/yy"
. Then you change the format:
$("#schedule").datepicker("option", "dateFormat", "dM-yy");
but value
already lost.
You must set the format when you bind datepicker:
$("#schedule").datepicker({ dateFormat: 'dM-yy' });
Demo: http://jsfiddle.net/ambiguous/mHyn7/
source share