Hi have an html helper that allows me to apply a different style to the ValidationForMessage.
My question is how to I tap into the validation event to either change a css element of the message or trigger some javascript?
My code looks like
public static MvcHtmlString ValidationStyledMessageFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper,Expression<Func<TModel, TProperty>> ex)
{
var result = htmlHelper.ValidationMessageFor(ex);
var res = string.Format("<span class=\"required-field\"></span> <span class=\"error required hidden\"><p>{0}<a class=\"close\" href=\"javascript:closeError();\"></a></p></span>", result.ToHtmlString());
return MvcHtmlString.Create(res);
}
As you can see I have a span with a class that is hidden. What I would like to happen is whenever the validation message should be shown I remove the hidden css class.
Any help would be much appreciated.