I have a website that looks like 
where is "Start Date" and "End Date" datepicker .
When creating a web page, I can fill in the values in these fields, but adding a datupicker to them removes the values.
I initialize datepicker so
$(function() {
var dates = $("#from, #to").datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 3,
onSelect: function(selectedDate) {
var option = this.id == "from" ? "minDate" : "maxDate",
instance = $(this).data("datepicker"),
date = $.datepicker.parseDate(
instance.settings.dateFormat ||
$.datepicker._defaults.dateFormat,
selectedDate, instance.settings);
dates.not(this).datepicker("option", option, date);
}
});
$("#from, #to").datepicker("option", "dateFormat", "dd/mm-yy");
});
and HTML looks like
<input class="new" type="text" id="from" name="from"/>
How do I get a datepicker so as not to clear the form field values when loading a web page?
source
share