How to Fix Mvc3 Ajax Validation Using Jquery
To make automatic validation using data annotation on a model on mvc3 c# we need: 1.) A model with data annotation (ex. required attribute)...
https://www.czetsuyatech.com/2012/04/c-mvc3-ajax-validation-with-jquery.html
To make automatic validation using data annotation on a model on mvc3 c# we need:
1.) A model with data annotation (ex. required attribute).
2.) Form with jquery declaration (jquery1.7, validate, validate unobtrusive, and unobtrusive-ajax. All are available under Scripts directory on an MVC template project. Note that you can update your jquery library using NuGet.
3.) App.config with <add key="ClientValidationEnabled" value="true"/> defined.
Normally, with this requirement validation should work fine. But if the form is served via ajax call, you need to rebind the form to the validator elements using the ff code:
1.) A model with data annotation (ex. required attribute).
2.) Form with jquery declaration (jquery1.7, validate, validate unobtrusive, and unobtrusive-ajax. All are available under Scripts directory on an MVC template project. Note that you can update your jquery library using NuGet.
3.) App.config with <add key="ClientValidationEnabled" value="true"/> defined.
Normally, with this requirement validation should work fine. But if the form is served via ajax call, you need to rebind the form to the validator elements using the ff code:
//your_div is the id of your element which contains the form $.validator.unobtrusive.parse($('#your_div'));
Post a Comment