jQuery unobtrusive validation ignores data-val-required message in MVC3


Staff member
I have used the method described <a href="http://blog.gauffin.org/2011/08/" rel="noreferrer">here</a> to localize my data annotation messages and basically it is working fine in normal form posts. I can see the localized validation message on client side as well.

However, problem occurs when I have a partial view that has the input fields to be validated and is loaded using an ajax call. For some reason, I get the default validation message ("This field is required") instead of my localized message that is set in data-val-required attribute of the element.

I have verified the following:<br>
1. I have included both "jquery.validate.min.js" and "jquery.validate.unobtrusive.min.js".<br>
2. I checked the ajax response and it does contain data-val-required attribute with localized message.

I have already tried the following solutions:<br>
1. I tried parsing the ajax response (that didn't work) as $.validator.unobtrusive.parse('form')<br>
2. Parsing dynamic content for validation as described <a href="http://xhalent.wordpress.com/2011/01/24/applying-unobtrusive-validation-to-dynamic-content/" rel="noreferrer">here</a>. Still no solution.

I have a pressing deadline and this is troubling me.