[javascript]代码库
/*****************************************************************************1********************************************************************/
// 手机格式检查
function mobileLayoutCheck(){
var mobile = document.getElementById("mobile").value;
document.getElementById('mobileDiv').style.visibility = "visible";
if (mobile != "") {
var re = /^(((13[0-9])|(15([0-3]|[5-9]))|(17([0-3]|[5-9]))|(18[0,5-9]))\d{8})$/;
var result = re.test(mobile);
if (result) {
return true;
}else {
document.getElementById('mobileDiv').className = "wrong";
$("#mobileError").html("手机格式错误!");
return false;
}
} else {
document.getElementById('mobileDiv').className = "wrong";
$("#mobileError").html("请填写手机!");
return false;
}
}
/***********************************************************************2**************************************************************/
// 手机检查
function mobileCheck() {
var mobile = document.getElementById("mobile").value;
document.getElementById('mobileDiv').style.visibility = "visible";
if (mobile != "") {
var re = /^(((13[0-9])|(15([0-3]|[5-9]))|(17([0-3]|[5-9]))|(18[0,5-9]))\d{8})$/;
var result = re.test(mobile);
if (result) {
// 判断是否已注册
$.ajax({
type : "POST",
url : contextpath + "shoppc/reg/findMobileInformation.do?mobile=" + mobile,
success : function(response) {
var result = $.parseJSON(response);
if (result.code == "0106") {// 已绑定
document.getElementById('mobileDiv').className = "wrong";
$("#mobileError").html(result.msg);
reg_checkMobile = false;
} else if (result.code == "0109") {// 已发送验证码
document.getElementById('mobileDiv').className = "yes";
$("#mobileError").html(result.msg);
reg_checkMobile = false;
} else if (result.code == "0124") {// 已注册帐号
document.getElementById('mobileDiv').className = "wrong";
$("#mobileError").html(result.msg);
reg_checkMobile = false;
}else { // 未注册
document.getElementById('mobileDiv').className = "yes";
$("#mobileError").html(result.msg);
reg_checkMobile = true;
}
}
});
// document.getElementById('mobileDiv').className = "yes";
// $("#mobileError").html("格式正确!");
// return true;
} else {
document.getElementById('mobileDiv').className = "wrong";
$("#mobileError").html("手机格式错误!");
reg_checkMobile = false;
}
} else {
document.getElementById('mobileDiv').className = "wrong";
$("#mobileError").html("请填写手机!");
reg_checkMobile = false;
}
}