Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Styling ASP.NET MVC validation errors?

Can ASP.NET MVC's validation errors be styled? Where? I tried editing .input-validation-error class in Site.css but that didn't have any effect.

pom

like image 514
Pompair Avatar asked May 17 '11 15:05

Pompair


People also ask

What is ValidationMessageFor?

ValidationMessageFor() is a strongly typed extension method. It displays a validation message if an error exists for the specified field in the ModelStateDictionary object.

What replaces Valmsg data?

data-valmsg-for is the name of the input associated to the error message(s) being displayed. data-valmsg-replace specified whether error messages are to be replaced within this element.


1 Answers

If you style up .field-validation-error then this will change the validation error text messages.

.field-validation-error{ color: red; font-weight: bold; }

If you style up .input-validation-error then this will change the input style when there is a validation error.

.input-validation-error{ background: pink; border: 1px solid red; }
like image 135
Tim B James Avatar answered Oct 15 '22 02:10

Tim B James