Reputation: 3786
We have ASP.NET MVC application using Telerik UI for ASP.NET MVC. On the page is set up a grid with popup editor, by kendo html helper.
Now I need to configure some custom validation rules for popup editor form. I can't find a way how to do it.
$("form")
. But there is no form in grid popup$("gridName").kendoValidator().data("kendoValidator")
, such rules are simply not fired when saving editor changesgridOnEditEvent.container.find("#editorcontent").kendoValidator().data("kendoValidator")
, for example, I can extend rules, validate and send form data manually, but standard save button of the popup editor doesn't reflect such configurationHow can extend validation rules of the grid popup editor validator?
Upvotes: 1
Views: 2719
Reputation: 872
Kendo widgets built with an HTML helper, such as the Grid, initialize their own internal Validator. Custom rules must be added to the Validator class itself in order to run in these inaccessible instances of the Validator. Telerik has an example of how to do this:
$.extend(true, kendo.ui.validator, {
rules: { // custom rules
productnamevalidation: function(input, params) {
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;
}
},
messages: { //custom rules messages
productnamevalidation: function(input) {
// return the message text
return input.attr("data-val-productnamevalidation");
}
}
});
Upvotes: 1