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:RequiredFieldValidato r ID="jobNoRequiredFieldVali dator" runat="server" ControlToValidate="jobNoTe xtBox" Display="dynamic"
ErrorMessage="Job No is required" Width="112px"></asp:Requir edFieldVal idator>
<asp:CustomValidator ID="jobNoCustomValidator" runat="server" ClientValidationFunction=" Min7Length " ControlToValidate="jobNoTe xtBox" Display="Dynamic" ErrorMessage="Job No is 7 characters in this format: 9999.99"
Width="264px"></asp:Custom Validator>
</InsertItemTemplate>
Thanks for any help on this
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:RequiredFieldValidato
ErrorMessage="Job No is required" Width="112px"></asp:Requir
<asp:CustomValidator ID="jobNoCustomValidator" runat="server" ClientValidationFunction="
Width="264px"></asp:Custom
</InsertItemTemplate>
Thanks for any help on this
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER