Reputation: 32500
This is my MVC registration page. You can see the validation error messages consolidated up top. The UI designers want red (*) to appear next to each control that needs attention.
I know how to use MVC 3 validation to produce either *'s or the error messages above by placing @Html.ValidationMessageFor and customizing error messages to be either *'s of the more detailed messages.
What I can't figure out is how to do both. I understand that I can solve this problem with JQuery. But I suspect that MVC validation has a way to do this. @Html.ValidationMessageFor seems to apply once for each model member / control so that is probably not the way...
So to summarize, is there a way for me to add a second error message (like *) for each control located in a different location than the original message with only MVC validation and no JQuery / JS.
Upvotes: 0
Views: 732
Reputation: 16928
As far as I know the validation feedback only supports one feedback string per input. You could set custom feedback messages for each one and put the * in front of the string but this breaks a lot of the convention over configuration benefit of MVC.
Now, that being said why not try CSS? As I understand it those feedback messages (when next to each input form) use a fixed css class. So maybe something along this line...
field-validation-error:before
{
content:"* ";
}
Upvotes: 1
Reputation: 680
Html.ValidationSummary at the top. Html.ValidationMessageFor next to each field.
Upvotes: 0