0
I have a form with a date period ('Start Date' and 'End Date'). The start date may not be less than the end date and the end date may not be less than the start date. These inputs are using the Jquery UI datepicker (Jqueryui 1.11.0 and Jquery 3.1.1).
I searched 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 it?