按“提交”时,如何避免回复验证?当按下提交时,页面重新加载/回发,然后它给我验证错误。
@model X.Models.ModelVm
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.Birthday, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Birthday, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Birthday, "", new { @class = "text-danger" })
</div>
</div>
.....
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Get data" class="btn btn-default"/>
</div>
</div>
</div>
}
我的ViewModel:
[Required]
[DataType(DataType.DateTime)]
public DateTime Birthday { get; set; }
答案 0 :(得分:2)
<AL/alext.h>
和ClientValidationEnabled
。UnobtrusiveJavaScriptEnabled
,jquery
,jquery.validate.js
。