﻿function CheckMobile(mobile)
{
    var reg0 = /^13\d{9}$/;   //130--139。至少7位
    var reg1 = /^153\d{8}$/;  //联通153。至少7位
    var reg4 = /^156\d{8}$/;
    var reg3 = /^158\d{8}$/;
    var reg2 = /^159\d{8}$/;  //移动159。至少7位
    var reg5 = /^150\d{8}$/;  //移动150。至少7位
    var my = false;
    if (reg0.test(mobile)) my = true;
    if (reg1.test(mobile)) my = true;
    if (reg2.test(mobile)) my = true;
    if (reg3.test(mobile)) my = true;
    if (reg4.test(mobile)) my = true;
    if (reg5.test(mobile)) my = true;
    return my;
}
function IsNum(str)
{
    var reg = /^\d+$/;
    if(reg.test(str))
    {
        return true;
    }
    else
    {
        return false;
    }
}
function IsDigit(e)
{
    if(!e)
    {
        e = window.event;
    }
    if((e.keyCode >= 48 && e.keyCode <= 57) || (e.keyCode >= 96 && e.keyCode <= 105) || e.keyCode == 8 || e.keyCode == 46)
    {
        return true;
    }
    else
    {
        event.returnValue = false;
        return false;
    }
}
//函数名：chkdate
//功能介绍：检查是否为日期
//参数说明：要检查的字符串
//返回值：false：不是日期  true：是日期
function chkdate(datestr)
{
    var lthdatestr
    if (datestr != "")
        lthdatestr= datestr.length;
    else
        lthdatestr=0;
    var tmpy="";
    var tmpm="";
    var tmpd="";
    //var datestr;
    var status;
    status=0;
    if ( lthdatestr== 0)
        return false;


    for (i=0;i<lthdatestr;i++)
    {
        if (datestr.charAt(i)== '-')
        {
            status++;
        }
        if (status>2)
        {
            //alert("Invalid format of date!");
            return false;
        }
        if ((status==0) && (datestr.charAt(i)!='-'))
        {
            tmpy=tmpy+datestr.charAt(i)
        }
        if ((status==1) && (datestr.charAt(i)!='-'))
        {
            tmpm=tmpm+datestr.charAt(i)
        }
        if ((status==2) && (datestr.charAt(i)!='-'))
        {
            tmpd=tmpd+datestr.charAt(i)
        }
    }
    year=new String (tmpy);
     month=new String (tmpm);
     day=new String (tmpd)
     //tempdate= new String (year+month+day);
     //alert(tempdate);
     if ((tmpy.length!=4) || (tmpm.length>2) || (tmpd.length>2))
     {
          //alert("Invalid format of date!");
          return false;
     }
     if (!((1<=month) && (12>=month) && (31>=day) && (1<=day)) )
     {
          //alert ("Invalid month or day!");
          return false;
     }
     if (!((year % 4)==0) && (month==2) && (day==29))
     {
          //alert ("This is not a leap year!");
          return false;
     }
     if ((month<=7) && ((month % 2)==0) && (day>=31))
     {
          //alert ("This month is a small month!");
          return false;
     }
     if ((month>=8) && ((month % 2)==1) && (day>=31))
     {
          //alert ("This month is a small month!");
          return false;
     }
     if ((month==2) && (day==30))
     {
          //alert("The Febryary never has this day!");
          return false;
     }
 
     return true;
}
