jquery validate没有在asp.net应用程序中触发

时间:2015-01-21 16:51:42

标签: jquery asp.net jquery-validate

我几个月没用过jquery而且已经生锈了。我试图使用验证插件,它不会像它应该的那样触发。这是我项目的代码:

<script src="js/jquery-1.11.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.maskedinput.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery-validate.js" type="text/javascript" charset="utf-8"></script>
<script src="js/createUser.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $("#frmCreateUser").validate({
            rules: {
                txtNewUsername: {
                    required: true
                },
                txtConfirmUsername: {
                    required: true,
                    //minlength: 5,
                    equalTo: "#txtNewUsername"
                },
                txtNewPassword: {
                    required: true,
                    //email: true
                },
                txtConfirmNewPassword: {
                    required: true,
                    equalTo: "#txtNewPassword"
                }
                //agree: "required"
            },
            messages: {
                txtNewUsername: "Please enter username",
                txtConfirmNewUsername: "Please confirm username",

                txtNewPassword: {
                    required: "Please provide a password",
                    //minlength: "Your password must be at least 5 characters long"
                },
                txtConfirmNewPassword: {
                    required: "Please provide a password",
                    //minlength: "Your password must be at least 5 characters long",
                    equalTo: "Please enter the same password as above"
                }
                //email: "Please enter a valid email address",
            }
        });

        $("#txtContactPhone").mask("(999) 999-9999", { placeholder: " " });

    });
</script>
</head>

<body>

   <form id="frmCreateUser" runat="server">
     <div style="align-content:center">
         <h1>Alabama Debt Recovery System</h1>
          <br />
          <h3><u>Create User</u></h3>
      </div>
      <table>
          <tr>
            <td>
                <table>
                    <tr>
                        <td>New Username:</td>
                        <td><asp:TextBox ID="txtNewUsername" runat="server" /></td>
                    </tr>
                    <tr>
                        <td>Confirm New Username:</td>
                        <td><asp:TextBox ID="txtConfirmUsername" runat="server" /></td>
                    </tr>
                    <tr>
                        <td></td>
                        <td></td>
                    </tr>
                    <tr>
                        <%--<td>Password:</td>
                        <td><asp:Label ID="lblPassword" runat="server" /></td>--%>
                        <td></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td>New Password:</td>
                        <td><asp:TextBox ID="txtNewPassword" runat="server" TextMode="Password" /></td>
                    </tr>
                    <tr>
                        <td>Confirm New Password:</td>
                        <td><asp:TextBox ID="txtConfirmNewPassword" runat="server" TextMode="Password" /></td>
                    </tr>
                    <tr>
                        <td><br /></td>
                        <td><br /></td>
                    </tr>
                    <tr>
                        <td><br /></td>
                        <td><br /></td>
                    </tr>
                    <tr>
                        <td><br /></td>
                        <td><br /></td>
                    </tr>
                    <tr>
                        <td><br /></td>
                        <td><br /></td>
                    </tr>
                    <%--<tr>
                        <td>UserId:</td>
                        <td><asp:Label ID="lblUserId" runat="server" /></td>
                    </tr>
                    <tr>
                        <td></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td>Username:</td>
                        <td><asp:Label ID="lblUsername" runat="server" /></td>
                    </tr>--%>
                </table>
            </td>
            <td>
                <table>
                    <tr>
                        <td>Entity Name:</td>
                        <td><asp:TextBox ID="txtEntityName" runat="server" /></td>
                    </tr>
                    <tr>
                        <td>Entity Address:</td>
                        <td><asp:TextBox ID="txtEntityAddress" runat="server" /></td>
                    </tr>
                    <tr>
                        <td>Entity City:</td>
                        <td><asp:TextBox ID="txtEntityCity" runat="server" /></td>
                    </tr>
                    <tr>
                        <td>Entity State:</td>
                        <td>
                            <asp:DropDownList ID="ddEntityState" runat="server" DataTextField="StateName" DataValueField="StateId" />
                            <%--<asp:TextBox ID="txtEntityState" runat="server" MaxLength="2" Width="20px" />--%>
                            &nbsp;&nbsp;Entity Zip:&nbsp;&nbsp;
                            <asp:TextBox ID="txtEntityZip" runat="server" Width="50px" />
                        </td>
                    </tr>
                    <tr>
                        <td>Contact First Name:</td>
                        <td><asp:TextBox ID="txtContactFirstName" runat="server" /></td>
                    </tr>
                    <tr>
                        <td>Contact Last Name:</td>
                        <td><asp:TextBox ID="txtContactLastName" runat="server" /></td>
                    </tr>
                    <tr>
                        <td>Contact Phone:</td>
                        <td><asp:TextBox ID="txtContactPhone" runat="server" /></td>
                    </tr>
                    <tr>
                        <td>Contact Email:</td>
                        <td><asp:TextBox ID="txtContactEmail" runat="server" /></td>
                    </tr>
                    <tr>
                        <td>Confirm Email:</td>
                        <td><asp:TextBox ID="txtConfirmEmail" runat="server" /></td>
                    </tr>
                    <tr>
                        <td>Using a Third Party:</td>
                        <td>
                            <asp:RadioButtonList ID="rblThirdParty" runat="server" RepeatDirection="Horizontal" TextAlign="Right">
                                <asp:ListItem Text="Yes" Value="YES" />
                                <asp:ListItem Text="No" Value="NO" />
                            </asp:RadioButtonList>
                        </td>
                    </tr>
                    <tr>
                        <td><br /></td>
                        <td><br /></td>
                    </tr>
                    <tr>
                        <td><asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" /></td>
                        <td><asp:Button ID="btnCancel" runat="server" Text="Cancel" OnClick="btnCancel_Click" /></td>
                    </tr>
                    <tr>
                        <td></td>
                        <td>
                            <asp:Label ID="lblMsg" runat="server" />
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td colspan="2"><h4>You are logged in as:</h4><asp:Label ID="lblUser" runat="server" /></td>
        </tr>
    </table>
</form>

提前谢谢!

0 个答案:

没有答案