This works fine:
@Html.ValidationMessageFor(m => m.Definition)
except for the fact that the text comes out black. I want it in red. So, I tried this:
@Html.ValidationMessageFor(m => m.Definition, null, new { style = "color: red" })
However, that is setting the message to NULL. It’s crazy that there is no overload that will take the htmlAttributes arg without the message arg….. argghhh!!!
What’s the most elegant way to accomplish this (without me having to write my own validation messages)?
Found the answer here: http://www.jstawski.com/archive/2011/05/12/asp.net-mvc3-change-validation-class.aspx
EDIT
Answer now here: http://jstawski.com/post/2011/05/13/ASPNET-MVC3-change-validation-class
Basically:
If you are using the ASP.net MVC3 built in validation such as
you can easily change the validation by overriding the CSS class field-validation-error like this: