For a while I’m into Kendo UI. It feels great, as this brings recollections of the Telerik Academy and my beginner experiences with a rich JS framework. Great as it is, it is half the size of ExtJS and a many functionalities take a lot of coding. And there is a hindrance, as the documentation is, well, a mild word is scarce and a better try is bleak. Telerik does compensate this with their support with unlimited tickets and great responses. So they tipped me with this little problem of mine.

Here we have a custom field validator rule, standard as it is.

$('form#formID'</code><code>).kendoValidator({
     rules: {
         fieldID: function(input){
             if(input.is("[id='fieldID']")) {
                 var value = input.val();
                 // validate with some code</code><code>
                 }
             }

             return true;
         }
     }
});

It is triggered on any change of the input. But not as the value is set with the val( ) function.

$('#fieldID').val('test');

So, what does trigger the custom validation. An hour or so experimenting with the various events and properties led me to the easy way of a ticket. The answer is easy enough to challenge my ego, but not trivial enough so here it is. The validator is triggered with the gain and loss of focus on the field. So one needs to do the actions with jQuery. Voila.

$('#fieldID').val('test').focusin().focusout();

Leave a Reply

Your email address will not be published. Required fields are marked *

22 − = 12