Link to home
Create AccountLog in
Avatar of lakhi
lakhi

asked on

Conditional validation in asp.net DetailsView

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
            <InsertItemTemplate>
              <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"
                Width="264px"></asp:CustomValidator>
            </InsertItemTemplate>

Thanks for any help on this
ASKER CERTIFIED SOLUTION
Avatar of Anurag Thakur
Anurag Thakur
Flag of India image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of lakhi
lakhi

ASKER

Thanks!