我有一個使用Bootstrap 3的MVC應用程序。我將MVC客戶端驗證添加到了我的表單中,並且工作正常。如果有錯誤,它會顯示錯誤信息並阻止回發。這是使用標準VS2015 MVC模板附帶的jQuery 1.10.2。回滾jQuery 3使MVC客戶端驗證失敗?
然後,我看到建議更新的NuGet去jQuery 3和愚蠢我決定讓它升級。這導致了JS錯誤,並使它成爲我的Bootstap菜單不起作用的任何客戶端驗證。
所以,我回滾到jQuery 1.10.2這並不容易。但是,現在我的MVC客戶端驗證不起作用。它允許表單做回發。我無法弄清楚需要做些什麼才能重新開始工作。
這裏是我的檢查:
的Web.config
<appSettings>
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
我的一個視圖模型性能的
[Required(ErrorMessage = "*Required")]
public string Sequence { get; set; }
查看我的_Layout.cshtml的
<div class="col-md-3">
<label class="control-label">Sequence</label>
@Html.TextBoxFor(m => m.Sequence, new { @maxlength = "6", @class = "form-control", autofocus = "autofocus" })
@Html.ValidationMessageFor(m => m.Sequence, null, new { @class = "text-danger" })
</div>
底
個@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryval")
@Scripts.Render("~/bundles/bootstrap")
@RenderSection("scripts", required: false)
BundleConfig.cs
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js",
"~/Scripts/DigitalBrushMaskedInput.min_1.4.1.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.validate*"));