此jquery函數適用於按鈕提交,但不適用於鏈接按鈕。爲什麼?jQuery鏈接按鈕錯誤
<html>
<head>
<script type="text/javascript">
$(document).ready(function() {
$("#form1").validate({
rules: {
<%= txtUserName.UniqueID %>: {minlength: 5, required: true},
<%= txtPassword.UniqueID %>: {minlength: 5, required: true},
<%= txtEmail.UniqueID %>: {required: true},
<%= txtURL.UniqueID %>: {required: true},
<%= chkbox.UniqueID%>: {required:true},
<%= textcredit.UniqueID %>:{required:true},
},
messages: {
<%= txtUserName.UniqueID %>: {
required: "Plaese enter your name",
minlength: "User name must be atleaet of 5 characters"
},
<%= txtPassword.UniqueID %>: {
required: "Plaese enter your password",
minlength: "Password must be atleaet of 5 characters"
},
<%= txtEmail.UniqueID %>:{ required: "Plaese enter your Email Id",},
<%= txtURL.UniqueID %>:{ required: "Plaese enter Website URL",},
<%= chkbox.UniqueID %>:{ required: "Plaese select this chek box",} ,
<%= chkbox.UniqueID %>:{
required: "Plaese select creditcard",
minlength: "User name must be atleaet of 5 characters"
},
}
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<table width="50%" cellpadding="2" cellspacing="4" style="border: solid 1px navy; background-color: #d5d5d5;">
</table>
</form>
</body>
如果您提供更多代碼,它可能會更有幫助。例如,究竟是服務器代碼輸出?這些值可能對jQuery沒有意義。 –
可能重複的http://stackoverflow.com/questions/649762/asp-net-linkbutton-imagebutton-and-jquery-validate – goodeye