kendo-labs / angular-kendo

A project to create a robust set of Angular.js bindings for Kendo UI widgets
474 stars 209 forks source link

Question about validation #250

Open tonfy opened 10 years ago

tonfy commented 10 years ago

Normal when the field in 'grid' control validate failed, the input will show tooltip. But I want more than that. Display a ‘×’ or ‘!’ icon in input when validate failed. I do not know how to achieve this function, can somebody help me?

YonatanKra commented 10 years ago

Hi, This isn't exactly an angular or angular-kendo question but here's my experience with it. I've used 2 methods in order to format my validations messages. 1) If you are using the native rules of kendo, you can use the "message" function in order to manipulate with jQuery and then add/remove any validation output you like anywhere on the screen. You could, for instance, bind your "x" or "i" which are in or near the input field to the kendo error elements. Thus, every time they are toggled you could show or hide your custom error area. This can be bound to an angular scope variable and then use ng-hide/show. Countless ways to use this. 2) If you are using custom rules (which is a much better solution, since it checks the fields every time the form is submitted or changed) you can add your jQuery logic/manipulation there so every time validation fails do "x" and on success hide the "x" (or "!" :)). Hope this helps :)