RequiredFieldValidator not working with RadioButtonList

S

shodson

I have the following code

What's your sport?
<asp:RadioButtonList ID="rblSport" Runat="server">
<asp:ListItem Value="golf">Golf</asp:ListItem>
<asp:ListItem Value="base">Baseball</asp:ListItem>
<asp:ListItem Value="soft">Softball</asp:ListItem>
<asp:ListItem Value="swim">Swimming</asp:ListItem>
<asp:ListItem Value="jfw">Just for Women</asp:ListItem>
</asp:RadioButtonList>
<asp:RequiredFieldValidator ID="reqSport" Runat="server"
ControlToValidate="rblSport" InitialValue="" Display="Static" Text="*"
ErrorMessage="Please select the sport you play" />

So if the user submits this form, and they have not selected a sport,
I'd expect the validator to catch it but it's not.

How can I get my validator to ensure that one of the sport radio
buttons are selected?

I'm using .NET 1.1 on XP Pro SP1
 
S

shodson

Never mind, this works, I just wasn't checking for Page.IsValid on the
button click event...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top