您好我正在创建一个mvc 4 appliaction,其中点击登录按钮它将显示一个引导模式我的登录是局部视图和登录按钮在我的布局局部视图内。在我的登录局部视图我已经注册点击它的按钮我正在显示我的registartion局部视图和在registartion局部视图中我想为此添加客户端验证跟随下面的方法
的web.config
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
layout.cshtml
<script src="~/Scripts/jquery-1.8.2.min.js"></script>
<script src="~/Scripts/jquery.validate.min.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
registration.cshtml
<script src="~/Contents/Common.js"></script>
@using System.Web.Optimization
@model BlueBusApp.Models.M_BLUEBUS_USERDETAILS
@using (Html.BeginForm(null,null,FormMethod.Post,new{id="registration"}))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<div class="modal-header" style="background-color: gainsboro">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Create New Account</h4>
</div>
<div class="modal-body" style="height: 300px">
<form id="frmLogin" class="form-horizontal" role="form">
<div class="form-group">
<div class="editor-label">
@Html.LabelFor(model => model.USER_EMAIL, "Email", new { @class = "control-label" })
</div>
<div class="editor-field">
@Html.TextBoxFor(model => model.USER_EMAIL, new { @class = "form-control", id="userModelEmail" })
@Html.ValidationMessageFor(model => model.USER_EMAIL)
</div>
</div>
<div class="form-group">
<div class="editor-label">
@Html.LabelFor(model => model.USER_PASSWORD, "Password", new { @class = "control-label" })
</div>
<div class="editor-field">
@Html.TextBoxFor(model => model.USER_PASSWORD, new { @class = "form-control inputTextBox",id="userModelPwd" })
@Html.ValidationMessageFor(model => model.USER_PASSWORD)
</div>
</div>
<div class="form-group">
<div class="editor-label">
@Html.LabelFor(model => model.USER_CONFIRMPASSWORD, "Confirm Password", new { @class = " control-label" })
</div>
<div class=" editor-field">
@Html.TextBoxFor(model => model.USER_CONFIRMPASSWORD, new { @class = "form-control",id="userModelCfmPwd" })
@Html.ValidationMessageFor(model => model.USER_CONFIRMPASSWORD)
</div>
</div>
<div class="editor-label">
@Html.LabelFor(model => model.USER_MOBILENO, "Your Mobile No", new { @class = " control-label" })
</div>
<div class="editor-field">
@Html.TextBoxFor(model => model.USER_MOBILENO, new { @class = "form-control",id="userModelMob" })
@Html.ValidationMessageFor(model => model.USER_MOBILENO)
</div>
<div class="form-group" style="margin-top: 40px; margin-left:200px; ">
<div class="col-sm-offset-2 col-sm-10">
<button id="btnRegister" type="button" class="btn btn-danger">Create My Account</button>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<a href="#" class="anchor-horizontal pull-left" id="modalLaunchBack">Back</a>
</div>
}
像这样我添加了。但为什么我的客户端验证不起作用