2 different DataAnnotation validation styles with css
I am using ASP.NET MVC 2, and am using the DataAnnotation for validation of fields on my website, but I would like for the error messages to have two different styles dep开发者_JS百科ending on the form. I know DataAnnotation uses these 2 css classes:
.input-validation-error
{
background-color: #ffeeee;
border: solid 2px #ff9999;
}
.validation-summary-errors
{
font-weight: bold;
color: #ff0000;
}
My question is, can you specify which css class the validations use, and if so how? Thank you guys for your help in advance. I have not had any luck finding this answer thus far.
You could give your forms different ids and adapt your CSS. Example:
<form action="/foo" method="post" id="form1">
...
</form>
<form action="/foo" method="post" id="form2">
...
</form>
and then have different CSS rules:
#form1 .input-validation-error
{
background-color: red;
border: solid 2px #ff9999;
}
#form2 .input-validation-error
{
background-color: blue;
border: solid 2px #ff9999;
}
精彩评论