jQuery unobtrusive validation in .NET MVC 3 - showing success checkmark

让人想犯罪 __ 提交于 2019-12-04 03:10:58
James Kolpack

This appears to be an issue with the jquery.validate.unobtrusive interfering with the settings added later in $.validator.setDefault. The trick is to load the unobtrusive script after the custom settings. See here and vote to fix it here.

In case any one has a similar problem, I finally got this working by using the un-minified version of jquery.validate.unobtrusive.js and adding my js to the onError and onSuccess methods. Existing code was left as it. Use the re-minified version during deployment.

Thanks.

This is not a direct answer to your question. I am going to offer an alternative approach to this: TwitterBootstrapMVC.

With this library all you'd have to write for each input is:

@Html.Bootstrap().ControlGroup().TextBoxFor(m => m.Address1)

And that's it. You will have label, input, and validation message - all taken care of, without javascript. It generates proper html mark up for you. You just need to make sure that you have proper standard css for classes like .field-validation-error, .field-validation-valid...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!