0

我正在使用 MVC3。我有一个运行良好的基本项目,并将默认 MVC 验证显示为红色。

现在验证虽然仍然有效,但显示为黑色而不是红色。除此之外一切都很好。

<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>

@Html.ValidationSummary(true, "Login was unsuccessful. Please correct the errors and try again.")

    @using (Html.BeginForm("Logon", "Research", 
            new { returnUrl = Request.QueryString["ReturnUrl"] }, FormMethod.Post, 
            new { @class = "form"}))
    {


                <div style="margin-top:20px">
                  @Html.LabelFor(m => m.UserName)
                  <div class="input">
                    @Html.TextBoxFor(m => m.UserName)                
                  </div>
                  <div class="input">
                    @Html.ValidationMessageFor(m => m.UserName)
                  </div>              
                </div>

                <div>
                  @Html.LabelFor(m => m.Password)
                  <div class="input">
                    @Html.PasswordFor(m => m.Password)                
                  </div>
                  <div class="input">
                    @Html.ValidationMessageFor(m => m.Password)
                  </div>
                </div>

                <div class="actions" style="margin-bottom:20px">              
                  <input type="submit" value="Log On" class="button" />
                </div>

    }
4

2 回答 2

2

在默认站点 css 文件中更改以下类:

.field-validation-error
{
    color: Black;
}

.validation-summary-errors
{
    font-weight: bold;
    color: Black;
}
于 2012-09-04T08:17:08.157 回答
-1

包括~/Content/css在您的布局中

于 2015-06-21T18:08:30.947 回答