TL;DR - I want to provide a custom field name but use the built-in validation messages.
I am trying to customize the validation messages displayed by the Kendo validator in a mobile application.
I've created a JsFiddle (http://jsfiddle.net/jeremy_wiebe/6nw8s/) to help show what's going on and the options for specifying validation options.
I am trying to customize the validation messages displayed by the Kendo validator in a mobile application.
I've created a JsFiddle (http://jsfiddle.net/jeremy_wiebe/6nw8s/) to help show what's going on and the options for specifying validation options.
- Don't provide anything, just let Kendo build the message using the input element's 'name' attribute. This is sub-optimal because the 'name' attribute doesn't allow spaces in it and 'customerNumber1 is required' doesn't look good.
- Specify a 'title' on the input. This is a start but kendo uses _only_ the 'title' attribute value for all validation messages. This is again sub-optimal when the input may become invalid for multiple reasons (required, min/max values, incorrect format, etc). Try putting '-100' the second field to see what I mean.
- Put a 'validationMessage' attribute on the input. As far as I can tell this is identical to doing #2. So it has the same shortcomings.
- Add custom data-{rule}-msg attributes for each type of validation you might have on the attribute. This solves the problem at the cost of making more verbose HTML. Now I have to put a custom validation message on each HTML input form for each validation rule I have.
Looking at the Kendo source I see that there's an object that stores the built-in validation rule messages. These messages use the kendo formatting (see the _extractMessage function) to display a message and have placeholders for the field name as well as any other dynamic validation bits that may be applicable for the message.
So, what I'd like to be able to do is specify the 'title' attribute on the input (referring to my JSFiddle I'd use 'Customer #' from the second <input>) and have the kendo validator use that as the field name when it formats the built-in validation messages. In this way the second input would show 'Customer # is required' if the field is empty and 'Customer # should be greater than or equal to 1' if the value is -11.
Is there any way to accomplish this as the code is now?
So, what I'd like to be able to do is specify the 'title' attribute on the input (referring to my JSFiddle I'd use 'Customer #' from the second <input>) and have the kendo validator use that as the field name when it formats the built-in validation messages. In this way the second input would show 'Customer # is required' if the field is empty and 'Customer # should be greater than or equal to 1' if the value is -11.
Is there any way to accomplish this as the code is now?