I have a web form using asp controls.
I am implementing validation into the form.
I've run into a little snag I can't seem to get past.
Here's the code:
Code:
<asp:RadioButton ID="CC" Text="Credit Card" GroupName="PayMethod" runat="server" />
<asp:RadioButton ID="Check" Text="Check/Money Order" GroupName="PayMethod" runat="server" />
<asp:DropDownList ID="CardType" runat="server">
<asp:ListItem Value="" Selected="true"></asp:ListItem>
<asp:ListItem Value="Visa">Visa</asp:ListItem>
<asp:ListItem Value="MC">MasterCard</asp:ListItem>
<asp:ListItem Value="Amex">American Express</asp:ListItem>
<asp:ListItem Value="Disc">Discover</asp:ListItem>
</asp:DropDownList>
What I want is if the Credit Card radiobutton is selected then the CardType dropdown must be validated. If the Check/Money Order radiobutton is selected, the dropdown will remain blank and I don't want to validate it.
I tried this right below the dropdown list:
Code:
<% If CC.checked = "True" then %>
<asp:RequiredFieldValidator ID="CardTypeRequired" ControlToValidate="CardType" runat="server" ErrorMessage="Credit Card Type">***</asp:RequiredFieldValidator>
<% End If %>
But the Validator runs whether CC.checked is true or false.
Not sure how to put the IF-THEN where it will work.
Any help is appreciated.
Thanks
-Tom
|