I'm using the client validation function of the MVC 2.0 framework
(with Html.ValidationMessageFor()
and Html.EnableClientValidation()
).
Everything is nice, when I use the validation in a simple form.
But when I get this form via jQuery Ajax
$.get('PathToMyForm', function(htmlResult) {
$('selector').html(htmlResult);
});
client validation doesn't work. Why?
If you are using jquery.validate (particularly with MVC) and you are loading pages via AJAX, you need to make the following call after the page loads:
$.validator.unobtrusive.parse($("#validation"));
See more at my blog post: Using Unobtrusive jQuery Validation with Forms Loaded via AJAX
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