10
votes

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

1

1 Answers

16
votes

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 = "";