Asp MVC unobtrusive Client Validation always returning true

三世轮回 提交于 2020-01-01 10:59:11

问题


We have a partial view that contains a form with unobtrusive client validation enabled.

If we load the partial view using Html.Action, the validation works on the client side.

If when the user clicks a link we use JQuery to populate a div with the partial view , the client validation always returns true.

Any idea what is going on?


回答1:


You need to parse the new html to hook up the validation controls. You can do this using:

$.validator.unobtrusive.parse( $('.selector' ) );

where the selector returns the container holding the new HTML. This is what I use with tabbed interfaces.



来源:https://stackoverflow.com/questions/6061941/asp-mvc-unobtrusive-client-validation-always-returning-true

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