ASP.NET MVC的ValidationSummary对于客户端验证 [英] ASP.NET MVC ValidationSummary For Client Side Validation

查看:96
本文介绍了ASP.NET MVC的ValidationSummary对于客户端验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的服务器端验证(通过数据注解)是伟大的工作,并张贴在我们的ValidationSummary中的错误,我们喜欢它。客户端验证也适用,但是错误显示的控制权,并验证摘要永远不会显示。有一个简单的方法,使客户端验证显示器看起来像服务器端验证显示?

Our server side validation (via data annotations) is working great and posts the errors in our ValidationSummary how we like it. The client side validation also works, however the errors display to the right of the control and the validation summary never displays. Is there an easy way to make the client validation display to look like that of server side validation display?

推荐答案

如果你在谈论使用ASP.NET MVC 2 preVIEW 2或使用的 jQuery验证库,你应该看看 errorLabelContainer errorContainer 为jQuery验证的文档中库

If you're talking about using ASP.NET MVC 2 Preview 2 or any other generated client side validation that uses the jQuery Validation library, you should check out errorLabelContainer and errorContainer in the documentation for jQuery Validation library.

这应该让你的客户端验证看起来更像是在服务器端验证摘要。 : - )

That should get your client side validation looking more like the server side validation summary. :-)

HTHS,结果
查尔斯

HTHs,
Charles

诗。如果你不能改变 $('myForm的')。验证()的选项,只需使用 $。validator.setDefaults() ; 办法。虽然你可能陷入困境与页面上有多个表/验证摘要。

Ps. If you can't alter the $('myForm').Validate()'s options, just use the $.validator.setDefaults(); approach. Although you could get into trouble with more than one form / validation summary on a page.

这篇关于ASP.NET MVC的ValidationSummary对于客户端验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆