MVC3 Force Validation of Hidden Fields
Asked Answered
H

1

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

Hennie answered 14/3, 2012 at 3:26 Comment(0)
H
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 = "";
Hennie answered 14/3, 2012 at 11:47 Comment(2)
Nice work this has been driving me nuts for a very long time :-)Reduce
Awesome!!!. I was looking for an answer. Hmm I need to start looking more into inner workings for MVC3 unobtrusive plugin.Stefaniestefano

© 2022 - 2024 — McMap. All rights reserved.