I am working with ASP.Net MVC3
, the easier way to use the client validation would be enabling the jquery.validate.unobtrusive
. Everything works fine, for stuff that's right from server.
But when I try to inject some new 'inputs' with javascript, and I knew that I need to call $.validator.unobtrusive.parse()
to rebind the validations. But still, all those dynamic injected fields are not functioning.
Even worse, I try to manually bind using jquery.validate
and it is not working either. Any thoughts?
I tried Xhalent's approach but unfortunately it wasn't working for me. Robin's approach did work and didn't work. It worked great for dynamically added elements, but if you tried to use JQuery to remove all the validation attributes and spans from the DOM, the validation library still would try to validate them.
However, if you remove the form's "unobtrusiveValidation" data in addition to "validationData", it worked like a charm for dynamically adding and removing elements that you want validated or not validated.
$("form").removeData("validator"); $("form").removeData("unobtrusiveValidation"); $.validator.unobtrusive.parse("form");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With