JQuery Validate - DropDown

时间:2012-04-02 20:13:29

标签: jquery-validate

我正在使用JQuery Validate插件来验证我的表单。我能够验证文本框但不能验证DropDown。有人能告诉我如何验证下拉列表吗?

<asp:FormView ID="fv_LeaveRequest" runat="server" DataKeyNames="REQ_ACTION_ID">
<InsertItemTemplate>
        <label>Leave Type</label>
        <asp:DropDownList ID="ddl_LeaveType" runat="server">
        </asp:DropDownList>
        <label>Leave Date</label>
        <asp:TextBox ID="tb_leaveDate" runat="server" CssClass="date"></asp:TextBox>
        <asp:Button ID="LeaveReqBtn" runat="server" Text="Submit Leave Request" CommandName="CustomInsert"
        CssClass="button-position" />
</InsertItemTemplate>
<ItemTemplate>            
        <asp:LinkButton ID="Edit" runat="server" Text="Edit / Change Request" CommandName="Edit" CssClass="button-position btn-padding" />           
        <label>Leave Type</label>
        <asp:DropDownList ID="ddl_LeaveType" runat="server">
        </asp:DropDownList>
        <label>Leave Date</label>
        <asp:TextBox ID="tb_leaveDate" runat="server" CssClass="date"></asp:TextBox>
</ItemTemplate>
<EditItemTemplate>           
        <asp:LinkButton ID="Cancel" Text="Cancel" CommandName="Cancel" runat="server" CssClass="button-position btn-padding" />
        <label>Leave Type</label>
        <asp:DropDownList ID="ddl_LeaveType" runat="server">
        </asp:DropDownList>
        <label>Leave Date</label>
        <asp:TextBox ID="tb_leaveDate" runat="server" CssClass="date"></asp:TextBox>
</EditItemTemplate>

$("#form1").validate({

        rules: {                  
                LeaveType: "required", 
                LeaveDate: "required"
            },
            messages: {
                LeaveType: "Select a value from DropDown", 
                LeaveDate: "This field is required"

            }
        });

0 个答案:

没有答案