我得到了我的#34;联系我"使用验证的形式,但我无法弄清楚如何显示错误消息。我已尝试阅读文档,但我不了解如何使用errorPlacement
函数。有人可以告诉我一个如何用我得到的代码做一个例子吗?
<fieldset>
<input placeholder="Ditt navn" name="contact_name" id="contact_name" class="contact_input" type="text" tabindex="1" required autofocus>
</fieldset>
<fieldset>
<input placeholder="Din email adresse" name="contact_mail" id="contact_mail" class="contact_input" type="email" tabindex="2" required>
</fieldset>
<fieldset>
<input placeholder="Firma navn (valgfri)" name="contact_firmname" id="contact_firmname" class="contact_input" type="text" tabindex="3">
</fieldset>
$(document).ready(function(){
$('body').on('keyup','#contact_me',function(){
$('#contact_me').validate({
rules: {
contact_name: {
required: true,
remote: location.protocol + '//' + location.host+'/ajax_contact.php'
},
contact_mail: {
required: true,
remote: location.protocol + '//' + location.host+'/ajax_contact.php'
},
contact_firmname: {
},
},
errorPlacement: function(){
return false;
},
submitHandler: function (form) {
return false;
}
});
});
});
答案 0 :(得分:0)
本文展示了您尝试在代码中重现的内容的可测试示例:https://www.webcodegeeks.com/javascript/jquery/jquery-errorplacement-example/