net_susan
asked on
Form Validate Pulldown (RequiredFieldValidator)
I want to do an asp:RequiredFieldValidator on the drop down below. How can I make the validator text activate if Food Types's selected value = 0?
<asp:DropDownList runat="server" id="Food Type">
<asp:ListItem Values="0" Selected="True">Please Select</asp:ListItem>
<asp:ListItem Value="1">Chicken</asp:Lis tItem>
<asp:ListItem Value="2">Beef</asp:ListIt em>
<asp:ListItem Value="3">Fish</asp:ListIt em>
</asp:DropDownList>
<asp:DropDownList runat="server" id="Food Type">
<asp:ListItem Values="0" Selected="True">Please Select</asp:ListItem>
<asp:ListItem Value="1">Chicken</asp:Lis
<asp:ListItem Value="2">Beef</asp:ListIt
<asp:ListItem Value="3">Fish</asp:ListIt
</asp:DropDownList>
use an compare validator whit the comparevalue=0 and the operator=greatherthan
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Both ways worked like this:
<asp:CompareValidator id="cv" runat="server" Operator="GreaterThan" ValueToCompare="0" Type="Integer" ControlToValidate="FoodTyp e">Please select your food type!</asp:CompareValidato r>
<asp:RequiredFieldValidato r ID="rvFood" ControlToValidate="FoodTyp e" Runat="server" InitialValue="0">Please select your food type!</asp:RequiredFieldVa lidator>
<asp:CompareValidator id="cv" runat="server" Operator="GreaterThan" ValueToCompare="0" Type="Integer" ControlToValidate="FoodTyp
<asp:RequiredFieldValidato