I\'ve got some dynamically inserted form fields on a page in an MVC3 project. Normally we would add the jQuery validation server-side, but in this case we can\'t (multiple
As it turns out, this can be done mostly in HTML by adding a few attributes to each form element:
name attributedata-val="true"data-val-required="message"Like so:
Then the form just needs to be re-parsed via JS:
//Remove current form validation information
$("form")
.removeData("validator")
.removeData("unobtrusiveValidation");
//Parse the form again
$.validator
.unobtrusive
.parse("form");