【问题标题】:Validation Summary with JQuery in MVC 2MVC 2 中 JQuery 的验证总结
【发布时间】:2010-05-12 04:09:21
【问题描述】:

我正在尝试在我的 asp.net mvc 2 Web 应用程序 (Visual Studio 2010) 上进行客户端验证。客户端验证IS 正常工作。但是验证摘要不是。

我包含以下脚本

<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)来纠正此问题,但它似乎存在一些更潜在的问题。

这个文件有更新/更好的版本吗?

【问题讨论】:

    标签: c# jquery asp.net-mvc jquery-validate


    【解决方案1】:

    到目前为止,我发现的最佳解决方案是来自 Ince 的补丁,可以在 jQuery.validate, and Html.ValidationSummary playing nice together 找到。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-30
      • 1970-01-01
      相关资源
      最近更新 更多