is there any default way in kendo DatePicker for ensuring (and alerting user accordingly) that To date is always greater than or equal to From date.
There is no default way but there is one example in Kendo UI demos page that might help you. Read here
Basically given this HTML:
<div class="demo-section" style="width:470px">
<label for="start">Start date:</label>
<input id="start" value="10/10/2011"/>
<label for="end" style="margin-left:3em">End date:</label>
<input id="end" value="10/10/2012"/>
</div>
And this DatePicker initialization:
var start = $("#start").kendoDatePicker({
change: startChange
}).data("kendoDatePicker");
var end = $("#end").kendoDatePicker({
change: endChange
}).data("kendoDatePicker");
start.max(end.value());
end.min(start.value());
They suggest the following startChange and endChange functions:
function startChange() {
var startDate = start.value();
if (startDate) {
startDate = new Date(startDate);
startDate.setDate(startDate.getDate() + 1);
end.min(startDate);
}
}
function endChange() {
var endDate = end.value();
if (endDate) {
endDate = new Date(endDate);
endDate.setDate(endDate.getDate() - 1);
start.max(endDate);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With