Put client side error messages where I want

Nov 23, 2009 at 2:37 PM


I'm using xVal 1.0 for an ASP.Net MVC project with great success so far, except I encounter an issue : I can't find a proper way to set where I want error messages on client side to show up.

By default they pop on right of the INPUT field concerned by the error. But I have TABLEs full of INPUT fields, so when an error pops, the layout of the table becomes a complete mess. Ideally I would like to declare a DIV over each TABLEs, and make errors messages being appended to it.

I've been trying many possibilities without success so far. I'm using jQuery.Validation and have noticed that the validate() method has an errorPlacement property, but I can't reach it through xVal.

Maybe I should rewrite the ClientSideValidation method, or maybe you have a better suggestion?

Thanks for your help.

Dec 18, 2009 at 3:45 PM


I'm assuming you're using the Html.EditorFor() helper?

If so, by default, the error messages show up to the right of the input field because of the templated helper associated with Object. See Brad Wilson's excellent article here:


To do what you're suggesting (placing a DIV over each table that contains error messages), I would use the .UseValidationSummary() method mentioned in the xVal 1.0 release blog:


Then jQuery/CSS the "validationSummary" div that gets output.