Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC3 Force Validation of Hidden Fields

I need to enable the validation of hidden fields using ASP.net MVC3 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.

I tried to use the following code but without success.

$("form").validate({
    ignore: ""
});

Thanks

like image 230
Fionn Avatar asked Mar 14 '12 03:03

Fionn


1 Answers

With a hint from this Question I was able to manipulate the options of the unobtrusive validator object.

var validator = $("#myFormId").data('validator');
validator.settings.ignore = "";
like image 141
Fionn Avatar answered Nov 21 '22 01:11

Fionn