I added a validation function to a field, but also all the other fields with validation: true get validated with this function which is totally wrong. Is that an intended behaviour?
1 Answer, 1 is accepted
0
Accepted
Vladimir Iliev
Telerik team
answered on 20 Jun 2014, 07:15 AM
Hi Stefan,
Basically current behavior is expected - in your validation function you should check if the current input element is the desired before executing the validation code. Please check the example below:
ProductName: {
validation: {
required: true,
productnamevalidation: function (input) {
if (input.is("[name='ProductName']") && input.val() != "") {
input.attr("data-productnamevalidation-msg", "Product Name should start with capital letter");
return /^[A-Z]/.test(input.val());
}
return true;
}
}
},
Also you can check the following demo of the grid with custom validation: