0

I am working on a MVC 4 project which requires to generate a specific markup when there is any error raise by the model validation.

suppose :

<div><i class="fa fa-info"></i><span>Error Message</span><div>

I have tried jquery to update the markup required on the event but that makes the code complex as too many client side events need attach on the DOM elements.

Thanks

Edit : Razor view engine generate a specific markup for

@Html.ValidationMessageFor(model => model.ModelProperty)

I want to customize the markup generated by the Razor View Engine for the above helper method without affecting the validation functionality.

Mayank
  • 1,351
  • 5
  • 23
  • 42

1 Answers1

0

The css class name for MVC validation message block is : .validation-summary-errors. You could find it easily with F12 inspector. So :

$(document).ready() {
   $('.validation-summary-errors').html('<span>' + $('.validation-summary-errors').html() + '</span>')
   $('.validation-summary-errors').prepend('<i class="fa fa-info"></i>') ; 
}
Perfect28
  • 11,089
  • 3
  • 25
  • 45