rules Object
Set of custom validation rules. Those rules will extend the built-in ones.
Defining custom rules
<form id="myform">
<input name="username"/> <br />
<input name="town" /> <br />
<button>Validate</button>
</form>
<script>
$("#myform").kendoValidator({
rules: {
customRule1: function(input){
// all of the input must have a value
return $.trim(input.val()) !== "";
},
customRule2: function(input) {
//only 'Tom' will be valid value for the username input
if (input.is("[name=username]")) {
return input.val() === "Tom";
}
return true;
}
},
messages: {
customRule1: "All fields are required",
customRule2: "Your UserName must be Tom"
}
});
</script>