<!-- 表单验证 --> <script src="http://static.runoob.com/assets/jquery-validation-1.14.0/dist/jquery.validate.min.js"></script> jQuery.validator.addMethod("testCellPhone", function (value, element, param) { var mobile = /^1(3|4|5|7|8)\d{9}$/; return mobile.test(value); }, $.validator.format("请输入正确的手机号!"));//验证手机号 13/4/5/7/8开头的11位数字 $(function () { $("#form").validate({ dubug: false, submitHandler: function (form) { sub(); }, rules: { cellPhone: { required: true, // 非空要求 testCellPhone: true //自定义要求 }, verifyCode: { required: true } }, messages: { cellPhone: { required: "手机号码不能为空", testCellPhone: "请输入正确的手机号" }, verifyCode: { required: "验证码不能为空" } } }); });var countdown = 90; //点击发送验证码, 90S后才能点击重新发送 function settime(obj) { if (countdown == 0) { obj.removeAttribute("disabled"); obj.value = "免费获取验证码"; countdown = 90; return; } else { obj.setAttribute("disabled", true); obj.value = "重新发送(" + countdown + ")"; countdown--; } setTimeout(function () { settime(obj) }, 1000) }
jquery 自带表单验证 validate 自定义验证
最新推荐文章于 2022-11-23 22:00:29 发布