I've created a MVC 5 form that dynamically adds fields using the editorfor function. The fields are automatically assigned new ids and names by MVC so that the property I've defined in my model is not the same id and name. This is causing MVC validation to fail to retrieve the error message I've specified in my properties data annotations. To rectify this I am attempting to assign a specific error message to the element. However, I cannot apply validator.showErrors to the element because when I attempt to validate the specific element the result is undefined. Why is var validator in the following code return undefined?
Thanks...
$('form').removeData("validator").removeData("unobtrusiveValidation");
$.validator.unobtrusive.parse($('form'));
var validator = $('#myClass_0__Age').validate();