﻿//验证输入是否为空
function checknull(name,price,tel)
{
    if (name == null || name == "") 
    {
        alert("姓名不能为空!");return false;
    }
    if(price == null || price == "" )
    {
        alert("金额不能为空!");return false;
    }
    if(tel == null || tel == "")
    {
        alert("电话不能为空!");return false;
    } 
    return true;
}

function checkname(name) {
    if ((/^[\x07-\xff]*$/.test(name))) {
        alert("请输入你的真实姓名!")
        return false;
    }  
    return true;
}

function checknumber(obj) {
    if (!(/^[0-9]*[1-9][0-9]*$/.test(obj))) {
        alert("周期必须为数字!");
        return false;
    }
    return true;
}

//验证金钱
function checkprice(price){
    
    if (!(/^[0-9]*[1-9][0-9]*$/.test(price))) {
        alert("金额输入有误,必须为数字!");
        return false;
    }
    return true;
}

function checktel(tel) {
//    var str=/^((0?1[358]\d)|((0(10|2[1-3]|[3-9]\d))?[1-9]\d))$/
    var str = /^(0?1[358]\d)|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$/
    if (!str.test(tel)) {
        alert("手机号输入有误!");
        return false ;
    }  
    return true;
}

//匹配手机号码
//匹配移动手机号"^1(3[4-9]|5[012789]|8[78])\d{8}$"                  
//匹配电信手机号"^18[0-9]\d{8}$"                   
//匹配联通手机号"^1(3[0-2]|5[56]|8[56])\d{8}$"           
//匹配CDMA手机号"^1[35]3\d{8}$"
function checkphone(tel) {
    var str = /^1(3[4-9]|5[012789]|8[78])\d{8}$/
    var str1 = /^18[0-9]\d{8}$/
    var str2 = /^1(3[0-2]|5[56]|8[56])\d{8}$/
    var str3 = /^1[35]3\d{8}$/
    if (str.test(tel)==true || str1.test(tel)==true || str2.test(tel)==true || str3.test(tel)==true) {

        return true;
    }
    else
    {
        alert("手机号输入有误!");
        return false;
    }

}

//密码验证
function checkpwd(pwd) {
    var str = /^[\w!@#$%\^&\*\(\)_]{6,20}$/
    if (!str.test(pwd)) {
        alert("密码输入有误,必须是4到16位,由数字、字母或特殊字符组成");
        return false;
    }return true;
}

function CheckNull(str1, str2) {
    if (str1 == "") {
        alert("真实姓名不能为空");
    }
    else {
        if (str2 == "") {
            alert("电子邮箱不能为空");
        }
        else {
            return true;
        }
    }
}


//验证邮箱
function checkemail(email) {
    str = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/
    if (str.test(email)) {
        return true;
    }
    else {
        alert("电子邮箱输入错误");
    }
}


