jQuery Datepicker for multiple inputs
Just change all id
to class
.
<input type="text" name="MyDate1" class="datepicker">
<input type="text" name="MyDate2" class="datepicker">
$(function() {
$( ".datepicker" ).datepicker({ dateFormat: "yyyy-mm-dd" });
});
also can use
$(function() {
$( "input[name^=MyDate]" ).datepicker({ dateFormat: "yyyy-mm-dd" });
});
Tired of repeating this, but still, am repeating it once more. id
s have to be unique. So, use this:
<input type="text" name="MyDate1" class="datepicker">
<input type="text" name="MyDate2" class="datepicker">
with
$(function() {
$( ".datepicker" ).datepicker({ dateFormat: "yyyy-mm-dd" });
});