我想在标签上显示必填字段验证消息,并希望在mvc 5中为多个字段使用单个标签,假设下面是我的代码:
<div class="col-sm-2">
@Html.TextBoxFor(model => model.MrnDate, new { id = "MrnDate", @class = "form-control", type = "Date", disabled = "disabled" })
<span class="error">Mrn. Date is Required</span>
</div>
我不想使用span标签。
发布于 2018-08-08 11:04:18
要在输入下包含验证错误,你可以@Html.ValidationMessageFor()
像这样使用:
@Html.ValidationMessageFor(model => model.MrnDate, "", new { @class = "text-danger" })
https://stackoverflow.com/questions/-100002007
复制相似问题