0

我想提请注意尚未通过模型验证的字段。例如,对于文本框,是否可以打印红色星号?

如:@Html.EditorFor(m => m.UserName)<span title="The User Name is required.">*</span>

4

1 回答 1

1

你有没有尝试过这样简单的事情:

@Html.ValidationMessageFor(model => model.UserName, "*")

您需要以下脚本:

<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="@Url.Content("~/Scripts/jquery-1.7.2.min.js")"></script>
<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>
于 2012-07-19T03:54:21.503 回答