views:

51

answers:

1

I have extended the ASP.NET MVC Html Helper to include my own ValidationImage that outputs an image rather than the standard tags. Details are shown within the StackOverflow Question: How do I extend Html.ValidationMessage so that I can include an image as the error?

I would like this to integrate well with xVal now. What would be the best method for doing this? How would I change the xVal.jquery.validate.js file to work with my error images?

Currently I have adjusted the xVal.jquery.validate.js file to work with the img tag rather than the standard span tag. I am receiving an error when the xVal.jquery.validate.js plug-in is trying to append something to the img tag. I assume it is trying to append the error text to the image tag which would cause an error.

What would be the best way to modify the xVal plug-in so that the error is added to the title attribute and the img tag is displayed into view?

A: 

A quick way to do this is to put your image into the attributes e.g.

[Required(ErrorMessage="<img src=\"error.gif\">")]
public string Forename { get; set; }

But its not ideal. Maybe a helper class could populate the error message or something like this.

RemotecUk
Actually, Id be interested to hear if you have a better method as your question was posted some time ago now :)
RemotecUk
I beleive that I created the Html helper class to use the images in the error messages.
Luke