I have a form with a date period ('Start date' and 'End date'). The start date can not be less than the end date and the end date can not be less than the start date. These inputs are using the datequicker of the JQuery UI (JQueryUI 1.11.0 and JQuery 3.1.1).
I looked in the Jquery UI documentation and found the example below:
$(function () {
var dateFormat = "dd/mm/yy",
from = $("#from")
.datepicker()
.on("change", function () {
to.datepicker("option", "minDate", getDate(this));
}),
to = $("#to").datepicker()
.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;
}
});
Is there any other way to do this?