Custom Validator

J

Joey

asp.net 2/C#/VS2005

I want to create a validator that will be able to check a drop-down
list box to make sure that the first item (index 0) is NOT selected.

Does anyone have any ideas about how to do this?
 
G

Guest

Hi Joey,

<asp:DropDownList runat="server" ID="choices">
<asp:ListItem Text="Please select..." Value="" />
<asp:ListItem Text="Choice 1" Value="1" />
<asp:ListItem Text="Choice 2" Value="2" />
<asp:ListItem Text="Choice 3" Value="3" />
</asp:DropDownList>
<asp:RequiredFieldValidator runat="server"
ID="choicesValidator"
ControlToValidate="choices"
Text="*"
Display="Dynamic"
EnableClientScript="true"
InitialValue="" />
<asp:Button runat="server" ID="submit" Text="Submit" />

Hope this helps
 

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