手机号,验证码

// 获取手机验证码
var phone = $('#phone');
var mobileReg = /^(13[0-9]|14[0-9]|15[0-9]|17[0-9]|18[0-9])\d{8}$/;
var getCode=$('#getCode');
getCode.on('click', function () {
if (allowGet) {
if (!mobileReg.test(phone.val())) {
alert('请输入正确格式的手机号~');
return;
}
updateTime();
$.getJSON('/user.d?m=regetvcode_lottery&phone=' + phone.val() + '&times=first', function (data) {
var status = data.root.status;
var message = data.root.message;
alert(message);
if (status !== '100') {
clearInterval(timer);
getCode.val('获取验证码').removeClass('getingCode');
timeCount = 60;
allowGet = true;
}
});
} else {
return;
}
});
// 提交验证码
var loginBtn = $('#loginBtn');
var inputCode = $('#inputCode');
loginBtn.on('click', function () {
if (!phone.val().trim()) {
alert('手机号不能为空~');
return;
}
if (!inputCode.val().trim()) {
alert('验证码不能为空~');
return;
}
login.hide().css(transInit);
floatAlert.fadeOut(300);
$.getJSON('/activity.d?m=checkVCode', {checkCode: inputCode.val(), phone: phone.val()}, function (data) {
var checkStatus = data.root.status;
if (checkStatus === '100') {
alert('登录成功~');
window.location.href = '/huodongAC.d?class=ChaiHongBaoHc&m=index';
} else {
alert('验证码错误,请重新输入~');
showLogin();
}
});
});
posted @ 2015-10-28 10:48  菜菜学长  阅读(364)  评论(0编辑  收藏  举报