MVC 2 中 JQuery 的验证摘要

发布于 2024-09-01 09:20:20 字数 1061 浏览 1 评论 0原文

我正在尝试在我的 asp.net mvc 2 Web 应用程序(Visual Studio 2010)上进行客户端验证。客户端验证正在工作。然而验证摘要却并非如此。

我包括以下脚本,

<script type="text/javascript" src="../../content/scripts/jquery-1.4.1.js"></script>
<script type="text/javascript" src="../../content/scripts/jquery.validate.js"></script>
<script type="text/javascript" src="../../content/scripts/MicrosoftMvcJQueryValidation.js"></script>

在此表单启动之前有此脚本

<% Html.EnableClientValidation(); %>

,并且表单内有

<%: Html.ValidationSummary("There are some errors to fix.", new { @class = "warning_box" })%>
<p>
    <%: Html.LabelFor(m => m.Name) %><br />
    <%: Html.TextBoxFor(m => m.Name) %>
    <%: Html.ValidationMessageFor(m => m.Name, "*") %>
</p>

我从 MvcFutures 下载的最新版本的 MicrosoftMvcJQueryValidation.js,但它看起来并不支持验证摘要。我尝试通过设置额外的选项(例如 errorContainer 和 errorLabelContainer)来纠正此问题,但看起来还有一些更根本的问题。

该文件是否有更新/更好的版本?

I'm trying to get client validation working on my asp.net mvc 2 web application (Visual Studio 2010). The client side validation IS working. However the validation summary is not.

I'm including the following scripts

<script type="text/javascript" src="../../content/scripts/jquery-1.4.1.js"></script>
<script type="text/javascript" src="../../content/scripts/jquery.validate.js"></script>
<script type="text/javascript" src="../../content/scripts/MicrosoftMvcJQueryValidation.js"></script>

Have this before this form is started

<% Html.EnableClientValidation(); %>

and inside the form is

<%: Html.ValidationSummary("There are some errors to fix.", new { @class = "warning_box" })%>
<p>
    <%: Html.LabelFor(m => m.Name) %><br />
    <%: Html.TextBoxFor(m => m.Name) %>
    <%: Html.ValidationMessageFor(m => m.Name, "*") %>
</p>

I have that latest version of MicrosoftMvcJQueryValidation.js from the MvcFutures download, but it doesn't look like it supports Validation Summary. I've tried correcting this by setting extra options such as errorContainer and errorLabelContainer, but it looks like there's some more underlying issues with it.

Is there an updated / better version of this file around?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浮生面具三千个 2024-09-08 09:20:20

到目前为止我找到的最好的解决方案是Since Ince 的一个补丁,可以在 jQuery.validate 和 Html.ValidationSummary 配合得很好

The best solution I've found so far is a patch by Since Ince that can be found at jQuery.validate, and Html.ValidationSummary playing nice together.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文