我是MVC的初学者,我想为我的MVC验证设置样式我该怎么办?
<div class="col-md-6">
@Html.ListBoxFor(a => a.QRefIds, new MultiSelectList(ViewBag.QltyRfs, "QReferenceId", "QReferenceCode"), new { Class = "form-control", title = "Select Feeder List", style = "width:575px;height:50px; margin-top:6px;font-size:small;" })
@Html.ValidationMessageFor(a => a.QRefIds)
</div>
答案 0 :(得分:3)
验证帮助程序生成一堆span
,其中包含类field-validation-error
,您可以使用CSS更改它:
.field-validation-error {
background-color:white;
border-radius:4px;
border: solid 1px #333;
display: block;
position: absolute;
top:0; right:0; left:0;
text-align:right;
}
当输入验证错误时,您还可以设置input-validation-error
的样式:
.input-validation-error{ background: pink; border: 1px solid red; }