Unobtrusive Validation with Kendo UI DropDownList

Unobtrusive Validation with Kendo UI DropDownList

aspnet-mvc

Really short post here. If you are trying to use jQuery unobtrusive validation with Kendo UI’s DropDownList , you might notice that it doesn’t work right out of the box. The form will simply validate, and will not actually check your selected value. This is a pain if you’re trying to validate that a field is required.

Since jQuery validate 1.9+, by default, hidden fields will not be checked for validation. This is a problem because Kendo stores selected DropDownList values in a hidden field.

In order to get around this, you need to tell jQuery validation not to ignore those fields. This can be done with some javascript that runs when your page loads:

$.validator.setDefaults({ ignore: ''});

Credit for the solution goes to Daniel from Telerik , but I wanted to share, because it took me a little while to figure out why this was happening. Hope this helps someone else out…

By | 2018-03-05T22:29:42+00:00 June 13th, 2015|Categories: ASP.NET, Misc. Fixes, MVC, Telerik|0 Comments

About the Author:

Leave A Comment