-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」}) –