Is it possible to customize the Html.ValidationMessageFor method so that it produces different HTML?
I want to do something similar to:
<div class="field-error-box">
<div class="top"></div>
<div class="mid"><p>This field is required.</p></div>
</div>
I am not sure if it’s possible to use
paragraph instead of defaultspan, as it may make impossible for validation plugin to place error messages. But for div -s, thats easy – you could write custom html helper.Something along these lines (may need further testing/coding). You will need to include the namespace of this static extension method in your view, or put this into
System.Web.Mvc.Htmldirectly.As you see, this uses default
ValidationMessageFormethod, to not interfere with validation-plugin error message processing.And you use this simply, as default validation message helper