【问题标题】:Jquery Validation Error asp.net mvc 3 - jquery.validate.min.jsjquery验证错误asp.net mvc 3 - jquery.validate.min.js
【发布时间】:2013-12-11 11:10:57
【问题描述】:

我正在学习 asp.net mvc 和 jquery。我在布局页面中使用了 jqueryui,以下是代码(使用 jquery 1.9.1 和 jqueryui 1.10.3):

<head>
<title>@ViewBag.Title</title>
<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/smoothness/jquery-ui-1.10.3.custom.min.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery-1.9.1.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-ui-1.10.3.custom.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/modernizr-2.5.3.min.js")" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        // JOIN - REGISTER BUTTONS 
        $("#btnSignIn").button({
            icons: {
                primary: "ui-icon-person"
            },
            text: true
        });
        $("#btnJoin").button({
            icons: {
                primary: "ui-icon-gear"
            },
            text: true
        });

        $('a').on('click', function (e) {
            e.preventDefault();
        });

        $('#ddmenu li').hover(function () {
            clearTimeout($.data(this, 'timer'));
            $('ul', this).stop(true, true).slideDown(200);
        }, function () {
            $.data(this, 'timer', setTimeout($.proxy(function () {
                $('ul', this).stop(true, true).slideUp(200);
            }, this), 100));
        });
    });
    </script>
</head>

以下是我的登录视图中的代码,我(相信我)有有效的参考:

        @model LayoutTest.Models.LogOnModel

    @{
        ViewBag.Title = "LogOn";
        Layout = "~/Views/Shared/_Layout.cshtml";
    }

    <h2>Log On</h2>
    <p>
        Please enter your user name and password. @Html.ActionLink("Register", "Register") if you don't have an account.
    </p>
    <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>


    @Html.ValidationSummary(true, "Login was unsuccessful. Please correct the errors and try again.")

参考其他 SO 帖子,我添加了正确的 jquery 脚本引用,但我仍然无法让它工作。附件是我在调用登录视图时收到的错误消息:

localhost:49436/Scripts/jquery.validate.min.js 中第 48 行第 199 列的未处理异常

0x800a138f - Microsoft JScript 运行时错误:无法获取属性“调用”的值:对象为空或未定义

【问题讨论】:

  • 看来我的问题与这里的帖子密切相关:stackoverflow.com/questions/14818363/… mvc3 的不显眼验证似乎在 1.8.3 版之后变得混乱。此外,由于 2+ jquery 不适用于 IE8 及更低版本,因此从 1.9.1 降级对我有用。希望有人能从中有所收获。

标签: jquery asp.net-mvc


【解决方案1】:

看来我的问题与 enter link description here 帖子密切相关,对 mvc3 的非侵入式验证似乎在 1.8.3 版之后变得混乱。此外,由于 2+ jquery 不适用于 IE8 及更低版本,因此从 1.9.1 降级对我有用。希望有人能从中有所收获

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-05
    • 1970-01-01
    • 2012-06-02
    • 2011-04-04
    • 2011-12-24
    相关资源
    最近更新 更多