我有一个简单的登录页面,突然(在将Jquery.js和Jquery-ui.js分别升级到1.10.2和1.10.3之后)开始实际到达操作结果而不是显示客户端验证消息EF数据注释。
所以我发现删除除了User和Password之外我唯一的CheckBoxFor,提交按钮实际上应该是这样的,这样它只会在不到达控制器的情况下提升客户端验证。
出现这种行为的原因是什么?
谢谢!
以下代码:
@using System.Web.Optimization;
@model MyProject.Models.LogOnModel
@{
ViewBag.Title = "Entrar";
}
<h1>@ViewBag.Title</h1>
<p>
Se pretende obter acesso clique @Html.ActionLink("aqui", "Register").
</p>
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryval")
@using (Html.BeginForm())
{
@Html.ValidationSummary(true, "O seu acesso falhou. Por favor corriga os erros e tente novamente.")
<div>
<fieldset>
<legend>Informação da sua conta</legend>
<div class="editor-field">
@Html.LabelFor(m => m.Email)
@Html.TextBoxFor(m => m.Email, new { @class = "medium-editor" })
@Html.ValidationMessageFor(m => m.Email)
</div>
<div class="editor-field">
@Html.LabelFor(m => m.Password)
@Html.PasswordFor(m => m.Password, new { @class = "medium-editor" })
@Html.ValidationMessageFor(m => m.Password)
</div>
<input type="submit" value="Entrar" />
@Html.CheckBoxFor(m => m.RememberMe)
@Html.LabelFor(m => m.RememberMe)
</fieldset>
</div>
}
<p>
Esqueceu a sua password?
Clique @Html.ActionLink("aqui", "ForgotPassword", "Account") para recuperar a sua password.
</p>
答案 0 :(得分:0)
要解决此问题,请在jquery之后包含jquery migrate 1.2.x
<script src="/Scripts/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.js"></script>