$().ready(function() { $("#form").validate({ rules: { pwd: { required: true, minlength: 8 }, confirmpwd: { required: true, minlength: 8, equalTo: "#pwd" }, agree: "required", verify: { required: true, remote: { url: "", //后台处理程序 type: "get", //数据发送方式 dataType: "json", //接受数据格式 data: { //要传递的数据 verify: function() { return $("#verify").val(); } }, dataFilter: function(data) { if (data == "true"){ $("#send_phonecode").removeAttr("disabled"); $("#send_phonecode").removeClass("btn_phonecode_disable"); }else{ $("#send_phonecode").attr("disabled",true); $("#send_phonecode").addClass("btn_phonecode_disable"); } return data; } }, minlength: 4 }, phonecode: { required: true, minlength: 6 } }, messages: { pwd: { required: "请输入密码", minlength: "密码长度不能小于 8 位" }, confirmpwd: { required: "请输入密码", minlength: "密码长度不能小于 8 位", equalTo: "两次密码输入不一致" }, //email: "请输入一个正确的邮箱", agree: "请接受我们的声明", phone: { required: "请输入手机号码", minlength: "手机号码至少11位数", remote: '该手机已经被注册' }, verify: { required: "请输入验证码", remote: '请输入正确的验证码', minlength: "验证码至少4位数" }, }, /*指定错误信息位置*/ errorPlacement: function (error, element) { error.appendTo(element.closest("p")); }, //设置错误信息存放标签 errorElement: "p", submitHandler: function(form) { form.submit(); } }); });
validate.js表单验证
最新推荐文章于 2024-08-12 08:53:53 发布