asp:dropdownlist上的html5验证

时间:2015-07-08 14:47:51

标签: asp.net html5 html5-validation

有没有办法在asp:dropdownlist上使用html5验证(不是asp:RequiredFieldValidator)。我已经尝试过了:

<asp:DropDownList ID="ExpenseLineTypeDdl" required="required" initialvalue="0" CssClass="form-control" runat="server">  
     <asp:ListItem Value="0">Please Select a Type</asp:ListItem>    
</asp:DropDownList>

我喜欢它与此类似的工作(除了asp:下拉列表):

<asp:TextBox runat="server" required="required"></asp:TextBox>

1 个答案:

答案 0 :(得分:2)

我必须摆脱{initialvalue =“0”}并设置初始listitem的{value =“”}:

<asp:DropDownList ID="ExpenseLineTypeDdl" required="required" CssClass="form-control" runat="server">  
      <asp:ListItem Value="">Please Select a Type</asp:ListItem>    
</asp:DropDownList>