None of the Microsoft validators have the ability to turn themselves on
based on another element of the page. There are two solutions.
1. Write a custom validator. If you want it to work on the client side, you
will have to figure out that code too.
2. I have written a replacement for Microsoft's validation, "Professional
Validation And More" (
http://www.peterblum.com/vam/home.aspx). Each of its
validators has a new property, "Enabler", where you can define a rule that
smartly enables the validator. On my RequiredTextValidator, you can set the
Enabler to look at the radiobutton before enabling itself. This works fully
on the client-side. In fact, Professional Validation And More's 22
validators support many more browsers on the client-side than Microsoft: IE,
IE/Mac, Netscape/Mozilla, Opera 7 and Safari.
--- Peter Blum
www.PeterBlum.com
Email:
PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
"News" <ge**@mailcity.com> wrote in message
news:y9********************@magma.ca...
Hi,
I am new to asp.net and unfortunately, have to learn as I go.
Here is a "problem".
I have got two radio buttons No and Yes and text box that has to be fiiled
in only if Yes is clicked. How can I validate this?
Here is a code:
<asp:radiobuttonlist RepeatDirection=Horizontal RepeatLayout=Table
id="is_override" runat="server">
<asp:listitem text="No" Value="0"></asp:listitem>
<asp:listitem text="Yes" Value="1"></asp:listitem>
</asp:radiobuttonlist>
<asp:requiredfieldvalidator
id="RequiredFieldValidator_is_override"
runat="server"
ErrorMessage="You must choose a valid Override option."
ControlToValidate="is_override">
</asp:requiredfieldvalidator>
<asp:textbox size=50 MaxLength="100" id="reason" runat="server" Text="" />
<!--- here I need some type of validation if a user cliked Yes --->
Help is very much appreciated!
Thanks