Conditional validation in asp.net DetailsView
Posted on 2012-03-14
I have a DetailsView I'm using to have users enter data. A couple of the fields have two validators. For example, a required field that also needs to be in a certain format. I don't want to show two error messages for one field.
I'm pretty sure this could be handled in the code behind but I'm not quit sure how to do it. (Sorry if it's messy, I wasn't sure how to include code in the message)
Here is an example of one of the fields I'm talking about
<asp:TextBox ID="jobNoTextBox" runat="server"
Text='<%# Bind("jobNo") %>' SkinID="TBInsert" MaxLength="7" width="144px/>
<asp:RequiredFieldValidator ID="jobNoRequiredFieldValidator" runat="server" ControlToValidate="jobNoTextBox" Display="dynamic"
ErrorMessage="Job No is required" Width="112px"></asp:RequiredFieldValidator>
<asp:CustomValidator ID="jobNoCustomValidator" runat="server" ClientValidationFunction="Min7Length" ControlToValidate="jobNoTextBox" Display="Dynamic" ErrorMessage="Job No is 7 characters in this format: 9999.99"
Thanks for any help on this