我使用jQuery验证插件。当validator.checkForm()为true时,serverSide中的onclick函数不会调用。如何调用changepass_Click fucntion? 我调试它,但点击后,页面重新加载,并没有去更改pass_Click fucntion。 这是我的HTML:
<div id="changePassDiv" runat="server" style="visibility: hidden; height: 85px;">
<fieldset id="changePassFieldset" runat="server">
<legend>legend</legend>
<table>
<tr>
<td>
<span>password</span>
</td>
<td>
<asp:TextBox ID="currentPass" runat="server" ClientIDMode="AutoID" TextMode="Password"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<span>new password</span>
</td>
<td>
<asp:TextBox ID="newPass" runat="server" TextMode="Password"></asp:TextBox>
</td>
</tr>
<td style="text-align: center">
<asp:ImageButton ID="btnValidate" runat="server" ImageUrl="~/images/send-50x20.png" BackColor="#a1c854"
Height="20px" CssClass="btnpadding1" Width="50px" OnClick="changepass_Click" />
</td>
<td style="text-align: center">
<asp:ImageButton ID="btnReturn" runat="server" ImageUrl="~/images/return-50x20.png" BackColor="#a1c854"
Height="20px" CssClass="btnpadding1" Width="50px" />
</td>
</tr>
</table>
<ul id="ErrorSection" class="validateError" runat="server">
</ul>
</fieldset>
</div>
这是我的jquery:
var validator = $('.form').validate({
rules: {
<%= currentPass.UniqueID %>: {
required: true,
maxlength: 25
}
},
errorClass: "error-label",
wrapper: "li",
errorLabelContainer: "#ErrorSection",
submitHandler: function(form) {
console.log(form)
$(form).submit();
}
});
$("#btnValidate").click(function (e) {
if (!validator.checkForm()){
e.preventDefault();
return;
}