/* 验证手机号码 公用JS函数*/
function check_phone(phone)
{
if(!phone){
alert('请输入手机号码!');
$("#phone").val(" ");
$("#phone").focus();
return false;
}else{
var reg =/^13[0-9]{1}[0-9]{8}$|15[0123689]{1}[0-9]{8}$|18[0-9]{1}[0-9]{8}$|17[0768]{1}[0-9]{8}$/;
if(!reg.test(phone))
{
alert("请输入正确的11位的手机号!");
$("#phone").val(" ");
$("#phone").focus();
return false;
}
}
return true;
}
/* 验证邮箱 公用JS函数 */
function check_mail(mail)
{
if(!mail){
alert('请输入邮箱!');
return false;
}else{
var reg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
if(!reg.test(mail))
{
alert("请输入正确的邮箱地址!");
return false;
}
}
return true;
}
/* 获取验证码 */
function get_Captcha_code()
{
var phone = $("#phone").val();
if(check_phone(phone))
{
$.ajax({
type:"POST",
url:"/index/set_SNS.html",
data:{phone:phone},
dataType:"json",
success: function(data){
if(data.status==true){
alert(data.msg);
return true;
}else{
alert(data.msg);
return false;
}
}
});
}
}
/* 4位验证码验证 公用JS函数 */
function check_code(phone,code)
{
var a;
if(!code){
alert('请输入4位数字验证码!');
$("#code").val(" ");
$("#code").focus();
return false;
}else{
var reg =/^[0-9]{4}$/;
if(!reg.test(code))
{
alert('请输入正确4位数字验证码!');
$("#code").val(" ");
$("#code").focus();
return false;
}else{
$.ajax({
type:"POST",
url:"/index/check_progress.html",
data:{phone:phone,code:code},
async: false,
dataType:"json",
success: function(data)
{
if(data.status===false)
{
alert(data.msg);
return false;
}
else
{
a ="ok";
}
}
});
}
}
return a;
}
打赏

感谢支持与鼓励~