Monday, 7 September 2015

Example date validation in kendo datepicker








function startChange() {

var fromDate = start.value(),

toDate = end.value();



if (fromDate) {

fromDate = new Date(fromDate);

fromDate.setDate(fromDate.getDate());

end.min(fromDate);

} else if (toDate) {

start.max(new Date(toDate));

} else {

toDate = new Date();

start.max(toDate);

end.min(toDate);

}

}



function endChange() {

var toDate = end.value(),

fromDate = start.value();



if (toDate) {

toDate = new Date(toDate);

toDate.setDate(toDate.getDate());

start.max(toDate);

} else if (fromDate) {

end.min(new Date(fromDate));

} else {

toDate = new Date();

start.max(toDate);

end.min(toDate);

}

}



var start = $("#FromDate").kendoDatePicker({

change: startChange

}).data("kendoDatePicker");



var end = $("#ToDate").kendoDatePicker({

change: endChange

}).data("kendoDatePicker");



start.max(end.value());

end.min(start.value());


No comments:

Post a Comment