自定义jquery验证器
customize jquery validator
我有以下代码:
<form id="reg_form_pay" class="fancy_form" action="" method="POST">
<div class="wrap_input" style="margin-bottom: 10px;">
<p class="inp_label">Firstname:</p>
<i> </i>
<input id="pay_firstname" type="text" value="" name="FirstName" style="width: 157px;">
</div>
<div class="wrap_input" style="margin-bottom: 10px;">
<p class="inp_label">Surname:</p>
<i> </i>
<input id="pay_lastname" type="text" value="" name="Surname" style="width: 157px;">
</div>
<div class="wrap_input" style="margin-bottom: 10px; margin-top: 34px;">
<p class="inp_label">E-mail:</p>
<i> </i>
<input id="pay_email" type="text" value="" name="Email" style="width: 157px;">
</div>
<div class="wrap_input" style="margin-top: 34px;">
<p class="inp_label">Phone:</p>
<i> </i>
<input id="pay_phone" type="text" value="" name="PhoneNumber" style="width: 157px;">
</div>
</form>
和验证:
$("#reg_form_pay").validate({
rules: {
Email: { required: true, email: true, checkEmail: true },
PhoneNumber: { required: true, checkPhoneNumber: true },
FirstName: { required: true },
Surname: { required: true }
},
});
默认情况下,验证程序在验证为false时写入label
。我不想添加带有错误描述的元素。我想将类error
添加到具有类wrap_input
的父div
中。我该如何对验证器说要这样做
谢谢
将其添加到发送到validate
的选项中即可:
showErrors: function(errorMap, errorList) {
$.each(errorList,function(i,e){
$(e.element).parents('.wrap_input').addClass('error');
});
}
现场示例:http://jsfiddle.net/nqp8J/
相关文章:
- 验证jquery中的数字
- 在发送之前验证jQuery或Javascript中的URL
- 提交/验证Jquery
- 验证 jQuery 中带有一个小数位的负数
- 如何验证 jquery cookie .js兼容性
- 验证 JQuery 中是否存在 URL
- 电子邮件验证 jquery
- 选择.js并验证 jquery
- 验证 jquery 评级星
- 如何为这些要求创建 URL 验证 jQuery
- 时间选择器验证?JQuery/Javascript
- 删除最近的下拉列表并验证Jquery中的下拉列表
- 验证jquery函数的问题
- 电子邮件验证Jquery不起作用
- 如何验证jquery函数中的输入字段
- 表单验证——jQuery验证是否足够,以及如何在PHP中巧妙地验证数据
- 当其他浏览器验证时,是什么导致I.E.不验证(jquery) ?
- 提交表单与ajax验证jquery /标准javascript
- 如何验证jquery中的表单
- 尝试验证jQuery UI日期选择器