I have an ASP.NET application that makes use of the built in validation controls. The end goal is to fire validation client side when the submit button is clicked, and add a class to a div element if it contains an invalid control. I'm basically trying to turn the label for the form element red if it's invalid. :)
I have markup like this (one div for each form element):
<div class="friendFormElement float_left bold">
First Name: * <asp:RequiredFieldValidator ID="rfv_fromFirstName" ControlToValidate="fromFirstName" Display="None" CssClass="validationError" ErrorMessage="From first name is required." runat="server" /> <br/>
<asp:TextBox ID="fromFirstName" runat="server" />
</div>
Using jQuery, how would I intercept the submit event, fire validation on the .NET validation controls, and then add an "error" class to the parent div element for each div that contains an invalid validator?
Bottom line is I'd like to add an "error" class to the div if it contains an invalid validator control. I'm open to other ideas for implementation as well.