I need to change the date format to insert it in database but unfortunately changing the dateFormat variable is not working. I have some validations to advance the date against the current date and to make the exceeding date un-clickable.
<script>
$( function() {
var dateFormat = "mm/dd/yy",
from = $( "#sd" )
.datepicker({
showOn: "button",
buttonImage: "images/cal-icon.png",
buttonImageOnly: true,
minDate: ("setDay, +4"),
maxDate: "+3M +10D",
changeMonth: true,
numberOfMonths: 2
})
.on( "change", function() {
to.datepicker( "option", "minDate", getDate( this ) );
}),
to = $( "#ed" ).datepicker({
showOn: "button",
buttonImage: "images/cal-icon.png",
buttonImageOnly: true,
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 2
})
.on( "change", function() {
from.datepicker( "option", "maxDate", getDate( this ) );
});
function getDate( element ) {
var date;
try {
date = $.datepicker.parseDate( dateFormat, element.value );
} catch( error ) {
date = null;
}
return date;
}
} );
</script>