0
我開始使用審定的jQuery插件,很不解,爲什麼它不工作,這是我的JavaScript代碼是: 「jQuery驗證不顯示錯誤消息
$(document).ready(function() {
$('#shipper_form').validate({
errorLabelContainer: "#errors",
rules: {
email: {
required: true,
email: true
},
business: "required",
address: {
required: true,
},
zipcode: {
required: true,
},
phone: {
required: true,
},
contact_name: {
required: true,
},
},
messages : {
email : "Required Email *",
business : "Required Business *",
address : "Required Address *",
zipcode : "Required Zip Code*",
phone : "Required Phone*",
contact_name : "Required Contact Name*",
},
submitHandler: function (form) {
return false;
}
});
});
</script>"
形式:
<div id="errors"></div>
<form method="post" action="signup.php">
<table cellspacing="4" cellpadding="4">
<tr>
<td>
<input type="text" id="email" name="email" style="width: 300px;" class="form-control placeholder" placeholder="Email Address">
<span id="email_success" class="glyphicon glyphicon-check" style="color: green; display: none;"></span>
</td>
</tr>
<tr>
<td>
<input type="text" id="business" name="business" style="width: 300px;" class="form-control placeholder" placeholder="Business Name or DBA">
<span class="glyphicon glyphicon-check" style="color: green; display: none;"></span>
</td>
</tr>
</table>
</form>
錯誤信息顯示爲電子郵件,但不是業務或任何其他人,我不知道我在做什麼錯。謝謝。
您的'#shipper_form'元素在哪裏?沒有元素具有該ID名稱... – Sergio
對不起,我在表單中忽略了id,即「id = shipper_form」,當我移動它時。 –
請在下面發佈您的解決方案作爲答案。 – Sparky