think I have a 2 text fields. Can I change there error messages according to text fields.
Here is a example.
1st text box is a email field and it is required field. So I keep it a error messages in a array :
["this field is required", "enter a valid e mail"]
2 text box is required field. Its error message :
["enter a valid value in the field"]
but in kendo ui validator like this ...
var validator = $("#formID").kendoValidator(
{ messages : {
required : "this field is required",
email : "enter a valid email address"
}
}).data("kendoValidator");
How I change these values dynamically according to the text fields error messages??
you can create
function
for bothrequired
andemail
to customize error messages according to html input fields.Script section:
Jsfiddle
Here in
getRequiredMessage
function i customized error message based on input name.I provided "User name is required" for input username. you can provide the error message even from array if you wish.