Monday, 18 November 2013

MVC Force Validation of Hidden Fields

I need to enable the validation of hidden fields using ASP.net MVC3/4 unobtrusive validation.
The reason behind this is a jquery plugin which hides the original input field to show something fancier.
But this disables validation of the field as it becomes hidden.

Finally i found perfect solution.
Now we are able to validate hidden field with following code.

$( document ).ready(function()
{
   var validator = $("#myFormId").data('validator');
   validator.settings.ignore = "";
});

Hope this help you.

No comments:

Post a Comment