10

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

Fionn
  • 10,975
  • 11
  • 54
  • 84

1 Answers1

16

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 = "";
Community
  • 1
  • 1
Fionn
  • 10,975
  • 11
  • 54
  • 84
  • Nice work this has been driving me nuts for a very long time :-) – Rob Nov 27 '12 at 13:03
  • Awesome!!!. I was looking for an answer. Hmm I need to start looking more into inner workings for MVC3 unobtrusive plugin. – parsh Jun 07 '13 at 18:43