Custom Validator

  • Thread starter Thread starter Joey
  • Start date Start date
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?
 
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
 
Back
Top