PDA

View Full Version : custom validation actions


reubenb
06-03-2009, 11:43 AM
hey

consider this asp.net form textbox with validation

<tr>
<td class="tbl2col1" id="firstnameFirst">Your first name?</td>
<td class="tbl2col2" id="firstnameSecond"><asp:TextBox ID="firstname" runat="server" />
<asp:RequiredFieldValidator ID="validateFirstname" runat="server" ControlToValidate="firstname"
ErrorMessage="* You must enter your first name." Display="dynamic">* </asp:RequiredFieldValidator></td>
</tr>


When the validation fails, it will add the red * to the text.

However, I want to change the class of element firstnameSecond to "tbl2col2 rederror". And then onchange when it gets rid of the *, i want the class of element firstnameSecond to go to "tbl2col2 greenerror".

How do I do this in ASP.Net?

Also - how do you make the class of the * not be 'style="color:Red;display:none;"', but be a style - like "redstar" or something.

Thanks