ASP MVC不干扰客户端验证始终返回true [英] Asp MVC unobtrusive Client Validation always returning true
问题描述
我们有一个局部视图,其中包含一个启用了不显眼的客户端验证的表单.
We have a partial view that contains a form with unobtrusive client validation enabled.
如果我们使用Html.Action加载部分视图,则验证将在客户端进行.
If we load the partial view using Html.Action, the validation works on the client side.
如果用户单击链接时我们使用JQuery填充具有局部视图的div,则客户端验证始终返回true.
If when the user clicks a link we use JQuery to populate a div with the partial view , the client validation always returns true.
知道发生了什么吗?
推荐答案
您需要解析新的html才能连接验证控件.您可以使用:
You need to parse the new html to hook up the validation controls. You can do this using:
$.validator.unobtrusive.parse( $('.selector' ) );
其中选择器返回包含新HTML的容器.这就是我在选项卡式界面中使用的.
where the selector returns the container holding the new HTML. This is what I use with tabbed interfaces.
这篇关于ASP MVC不干扰客户端验证始终返回true的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!