在我的模型我与[Required]
属性MVC必需的属性没有被拾起
[Required]
public string Surname { get; set; }
在我看来,我有ValidationMessageFor()
HTML辅助
<div class="form-group">
@Html.LabelFor(model => model.Surname, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Surname, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Surname, "", new { @class = "text-danger" })
</div>
</div>
但是它并没有说该财产当我去提交时,该字段是必需的。我在这里做错了什么?
已包含相关脚本('jquery','jquery.validate'和'jquery.validate.unobtrusive')? –