1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
| var inter;
function sendSMS() { var validator = $("#myForm").data('bootstrapValidator'); validator.validateField("user_tel"); var flag = validator.isValidField("user_tel"); console.log(flag); if (flag) { inter = setInterval("showCount()", 1000); $(".qrcode").attr("disabled", true);
$.post("${pageContext.request.contextPath}/sms", { "methodName": "sendSMS", "phoneNum": $("#user_tel").val() }, function (data) { console.log(data); }, "json"); } }
var count = 6; function showCount() { $(".qrcode").text(count + "S"); count--; if (count < 0) { clearInterval(inter); $(".qrcode").text("发送验证码"); count = 6; $(".qrcode").attr("disabled", false); } }
$(function () { $("#myForm").bootstrapValidator({ message: "this is no a valiad field", fields: { user_tel: { message: "手机号格式错误", validators: { notEmpty: { message: "手机号不能为空" }, stringLength: { message: "手机号长度为11", min: 11, max: 11 }, regexp: { message: "手机号格式不对", regexp: /^[1]{1}[1356789]{1}[0-9]+$/ } } }, user_password: { message: "密码格式错误", validators: { notEmpty: { message: "密码不能为空" }, stringLength: { message: "密码长度为6~8", min: 6, max: 8 }, regexp: { message: "密码由小写字母、数字组成", regexp: /^[a-z0-9]+$/ }, different: { message: "密码不能和手机号一致", field: "user_tel" } } }, qrCode: { message: "验证码格式错误", validators: { notEmpty: { message: "验证码不能为空" }, stringLength: { message: "验证码长度为4", min: 4, max: 4 } } } } }); })
|