Hi Team,
I am using the Kendo DateTimePicker and validator to validate the dates. Please find the below code. The issue I am having is that I see the "error message" for all the fields even thought rules returns true for those field. For example, I see the error message for the fields that have return value "false" which is fine. However, after running the validator, once I click on each field, I see the error message for that field. Even though these field have return value "true" from the function I have attached. I do not understand why I see the error message for all the fields.
1) What I want is I have two conditions in the function (if, else if). If these conditions get true, I want to display the error message. Otherwise, no error message needs to display because those dates are valid.
2) Is there a way to clear/reset the error message if there is any for a specific date field.
I really appreciate your help team. Please get back to me as soon as you can, I am waiting for your relpy.
function executeMaxMinValidationOnEachDate(datesArray) {
//$("#validateEditableFields").kendoValidator({
var minDate = 0;
var maxDate = 2;
var validator = $("#validateEditableFields").kendoValidator({
rules: {
datepicker: function (input) {
var currDate = kendo.parseDate(input.val()).getTime();
if (maxDate === 10) {
if (input.is("[data-role=datetimepicker]") && currDate < datesArray[minDate]) {
return false;
}
}
else if (input.is("[data-role=datetimepicker]") &&
(currDate < datesArray[minDate] || currDate > datesArray[maxDate])) {
minDate++;
currentDate++;
maxDate++;
return false;
//return input.data("kendoDateTimePicker").value();
} else {
minDate++;
currentDate++;
maxDate++;
return true;
}
}
},
messages: {
datepicker: "Please enter valid date!$$$$"
}
}).data("kendoValidator");
validator.validate();
}