1
我正在學習asp.net mvc和jquery。我在我的佈局頁中使用jQueryUI的,下面是代碼(使用jQuery 1.9.1和jQueryUI的1.10.3):jquery驗證錯誤asp.net mvc 3 - jquery.validate.min.js
<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腳本引用,但我仍然無法得到這個工作。附件是錯誤消息調用登錄查看時,我得到:在48行
未處理的異常,列199在本地主機:49436 /腳本/ jquery.validate.min.js
0x800a138f - 微軟JScript運行時錯誤:無法獲取屬性「call」的值:對象爲空或未定義
看來,我的問題是密切相關的帖子在這裏:http://stackoverflow.com/questions/14818363/mvc3-unobtrusive-validation-not-working-in-ie unobtrusive驗證對於mvc3在版本1.8.3後似乎已經不合時宜了。另外,由於2+ jquery不適用於IE8及以下版本,因此從1.9.1降級對我來說確實有竅門。希望有人從中得到一些東西。 – Purusartha