答案 0 :(得分:2)
需要考虑的几件事情:
1)在您的视图中,您应该引用jquery验证和不引人注目的JavaScript库:
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
2)同样在你看来,你应该有一个Html.ValidationMessageFor(m =&gt; m。属性):
@Html.ValidationMessageFor(x => x.UserName)
3)最后,确保您的web.config文件中有两个启用客户端验证的AppSettings。
<appSettings>
<add key="ClientValidationEnabled" value="true"/>
<add key="UnobtrusiveJavaScriptEnabled" value="true"/>
</appSettings>