-1
我想在我的cshtml文件中设置正则表达式,请问我是如何做到的?我不想在代码中使用正则表达式。如何在asp mvc中的cshtml razor文件中设置正则表达式?
<div class="form-group">
@Html.LabelFor(model => model.Title, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Title, new { htmlAttributes = new { @class = "form-control", placeholder = "short name", required = "required", RegularExpressionAttribute = @"^([a-zA-Z .&'-]+)$" } })
@Html.ValidationMessageFor(model => model.Title,"", new { @class = "text-danger" })
</div>
</div>
感谢回答其工作@kblau –
和如何使用验证消息模式不使用:@ Html.ValidationMessageFor(model => model.Name,Resources.Milsa.Milsa_RequiredField,new {@class =“text-danger”}) –