$(
function
(){
$(
"input[type='tel']"
).keyup(
function
(){
var
reg = /^\d*$/;
if
(
this
.value.length > 11){
this
.value =
this
.value.substr(0,11);
$(
this
).focus();
}
else
if
(!reg.test(
this
.value)){
$(
this
).parent().next().show().html(
"手机号码只能为数字"
);
$(
this
).focus();
}
else
{
$(
this
).parent().next().hide();
}
}).blur(
function
(){
if
(
this
.value ==
""
){
$(
this
).parent().next().show().html(
"手机号码不能为空"
);
$(
this
).focus();
}
else
if
(!/^1[3|4|5|8]\d{9}$/.test(
this
.value)){
$(
this
).parent().next().show().html(
"请输入正确的手机号码"
);
$(
this
).focus();
}
else
{
$(
this
).parent().next().hide();
}
})
$(
"#getCode"
).click(
function
(){
$(
"input[type='tel']"
).trigger(
'blur'
);
var
time = 120;
var
error = $(
this
).parent().prev().css(
"display"
);
alert(error);
alert(error !=
"block"
);
var
phoneNum = $(
"input[type='tel']"
).val();
if
(phoneNum !=
""
&& error !=
"block"
){
$.ajax({
type:
"post"
,
url:
"/Ajax/VerificationCode.ashx"
,
dataType:
"json"
,
data:{
method:
"SendCode"
,
Phone:phoneNum
},
success:
function
(data){
if
(data.reslut.msg == 1){
var
t = setInterval(
function
(){
time--;
$(
this
).attr(
"disabled"
,
true
).addClass(
"grey"
)
.html(time+
"s<p style='font-size:10px'>已发送</p>"
)
if
(time == 0){
clearInterval(t);
$(
"#getCode"
).removeAttr(
"disabled"
).removeClass(
"grey"
).html(
"重新获取验证码"
);
}
},1000);
}
else
{
alert(data.result.msbox);
}
}
});
}
})
$(
"#yzm"
).keyup(
function
(){
var
reg = /^\d*$/;
if
(
this
.value.length > 6){
this
.value =
this
.value.substr(0,6);
}
else
if
(!reg.test(
this
.value)){
$(
this
).parent().next().show();
$(
this
).focus();
}
else
{
$(
this
).parent().next().hide();
}
}).blur(
function
(){
if
(
this
.value ==
""
){
$(
this
).parent().next().show().html(
"验证码不能为空"
);
}
else
if
(
this
.value.length < 6){
$(
this
).parent().next().show().html(
"验证码必须为6位数字"
);
}
})
$(
"input[name = 'password']"
).blur(
function
(){
if
(
this
.value.length < 6||
this
.value.length > 20){
$(
this
).parent().next().show();
}
else
{
$(
this
).parent().next().hide();
}
})
$(
"input[name= 'password-sure']"
).keyup(
function
(){
var
password = $(
"input[name = 'password']"
).val();
if
(
this
.value != password){
$(
this
).parent().next().show();
}
else
{
$(
this
).parent().next().hide();
}
}).blur(
function
(){
if
(
this
.value ==
""
) {
$(
this
).parent().next().show().html(
"密码不能为空"
);
}
})
$(
"#submit"
).click(
function
(){
$(
".mui-input-row input"
).triggerHandler(
'blur'
);
var
numError = $(
'.mui-input-row + div'
).css(
"display"
);
if
(numError ==
"block"
){
return
false
;
}
$.ajax({
type:
"post"
,
url:
"/Ajax/User.ashx"
,
dataType:
"json"
,
data:{
method:
"Reg"
,
Phone: $(
"input[type = 'tel']"
).val(),
Pwd: $(
"input[name = 'password']"
).val(),
Code: $(
"#yzm"
).val()
},
success:
function
(data){
var
result = data.split(
"|"
);
if
(result[0] ==
"error"
) {
alert(result[1]);
}
if
(result[0] ==
"success"
) {
alert(result[1]);
window.location.href=
"registerSuccess.html"
;
}
}
})
})
})