我在我的 asp.net mvc Web 应用程序中有以下视图:-
@using (Ajax.BeginForm("CheckUserPermision", "SecurityRole",
new AjaxOptions
{
HttpMethod = "get",
InsertionMode = InsertionMode.Replace,
LoadingElementId = "progress2",
UpdateTargetId = "userSecurityRole"
}))
{
<div>
<span class="f">User Name </span>
<input name="username" type="text" data-val="true" data-val-required= "Please enter a value." data-autocomplete-source= "@Url.Action("AutoComplete", "SecurityGroup")" />
<span class="field-validation-valid" data-valmsg-for="username" data-valmsg-replace="true"></span>
</div>
目前,除非在“用户名”字段中输入文本,否则用户将无法进行搜索。但我的问题是天气使用data-val="true
“强制要求字段验证的正确方法?