function FormIsempty(_s)
{
	if(!_s) return true;
	if(_s.replace(/(^\s*)|(\s*$)/g, "")=="") return true;
	return false;
}

function FormIsdate(strDate)
{
    var strCheckDate = strDate+"";     //进一步确认哪来判断的肯定是一串字符串
         
    if(strCheckDate == "")        //空字符串,不是合法的日期字符串，返回false
    {
        return false;
    } 
    debugger;
    //判断传进来的数据是那种格式写成日期
    var intIndex = -1;         //利用正则表达式，查找字符串中是否包含某个字符，没找到为-1,否则为 （0 - String.length - 1）
    var arrDate;          //分别存储年月日
    var regExpInfo = /\./;        //正则表达式，匹配第一个出现 "."的位置
         
    //在这里，我之所以不使用replace函数把所有的"."和"/"换成"-",然后分别存储年月日，是因为用户有可能输入 2001/3-2,就判断不出它是不合法日期了
    intIndex = strCheckDate.search(regExpInfo);   //查找是否含有 "."
    if(intIndex == - 1)         //不包含  
    {
        regExpInfo = /-/;
        intIndex = strCheckDate.search(regExpInfo);
          
        if(intIndex == -1)
        {
            regExpInfo = /\//;       //查找是否含有 "/"
            intIndex = strCheckDate.search(regExpInfo); 
           
            if(intIndex == -1)
            {
                arrDate = new Array();  //只包含年或格式为20010307
                if(strCheckDate.length==4)
                {
                    arrDate[0]=strCheckDate;
                }
                else if(strCheckDate.length==6)
                {
                    arrDate[0]=strCheckDate.substring(0,4);
                    arrDate[1]=strCheckDate.substring(4,6);
               
                }
                else if(strCheckDate.length==8)
                {
                    arrDate[0]=strCheckDate.substring(0,4);
                    arrDate[1]=strCheckDate.substring(4,6);
                    arrDate[2]=strCheckDate.substring(6,8);
                
                }
                else
                {
                    return false;
                }
            }
            else
            {
                arrDate = strCheckDate.split("/");  //2001/3/7 型
            }
        }
        else
        {
            arrDate = strCheckDate.split("-");   //2001-3-7 型
        }
    }
    else
    {
        arrDate = strCheckDate.split(".");    //2001.3.7 型
    }
         
    if(arrDate.length > 3)        //如果分离出来的项超过3，除了年月日还有其它的，不合法日期，返回false
    {
        return false;
    }
    else if(arrDate.length > 0) 
    {
        //判断年是否合法
        if(fnIsIntNum(arrDate[0]))   //是正整数
        {
            if(parseInt(arrDate[0]) < 1 || parseInt(arrDate[0]) > 9999)  //年范围为1 - 9999
            {
                return false;
            } 
        }
        else
        {
            return false;     //年不是正整数，错误
        }
           
        //判断月是否合法
        if(arrDate.length > 1)
        {
            if(fnIsIntNum(arrDate[1]))  //是正整数
            {
                if(parseInt(arrDate[1]) < 1 || parseInt(arrDate[1]) > 12)
                {
                    return false;
                } 
            }
            else
            {
                return false;
            }
        }
        
           
        //判断日是否合法
        if(arrDate.length > 2)
        {
            var tmpDate=Trim(arrDate[2]);
            var tmpTime="";
            if(tmpDate.indexOf(" ")>0){
                aTmpDateTime=tmpDate.split(" ");
                if(aTmpDateTime.length!=2) return false;
                tmpDate=aTmpDateTime[0];
                tmpTime=aTmpDateTime[1];
                tmpTime=tmpTime.split(":");
                if(tmpTime.length!=3) return false;
                
                if(!FormIsnumeric(tmpTime[0])) return false;
                if(parseInt(tmpTime[0])<0||parseInt(tmpTime[0])>23) return false;
                
                if(!FormIsnumeric(tmpTime[1])) return false;
                if(parseInt(tmpTime[1])<0||parseInt(tmpTime[1])>59) return false;
                
                if(!FormIsnumeric(tmpTime[2])) return false;
                if(parseInt(tmpTime[2])<0||parseInt(tmpTime[2])>59) return false;
                
            }

            if(fnIsIntNum(tmpDate))  //是正整数
            {
                var intDayCount = fnComputerDay(parseInt(arrDate[0]),parseInt(arrDate[1]));
                if(intDayCount < parseInt(tmpDate))
                {
                    return false;
                }   
            }
            else
            {
                return false;
            }
        }
            
    }
    return true;
}

//**********************************************************************************************************
        //判断一个数是否为正整数
        //参数：strNum ---- 需要判断的字符串
        //返回值：true ---- 整数 false ---- 非整数
        function fnIsIntNum(strNum)
        {
         var strCheckNum = strNum + "";
         if(strCheckNum.length < 1)         //空字符串
          return false;
         else if(isNaN(strCheckNum))         //不是数值
          return false;
         else if(parseInt(strCheckNum) < 1)       //不是正数
          return false; 
         else if(parseFloat(strCheckNum) > parseInt(strCheckNum)) //不是整数 
          return false;
         
         return true;
        }

//**********************************************************************************************************
//功能：判断intYear年intMonth月的天数
//返回值：intYear年intMonth月的天数
function fnComputerDay(intYear,intMonth)
{
    var dtmDate = new Date(intYear,intMonth,-1);
    var intDay = dtmDate.getDate() + 1;
    
    return intDay;    
}
//验证Email是否正确
function FormIsemail(fData)
{
    var reEmail = /^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)/;
    return fData.match(reEmail);
}


//判断一个数是否为数字
function FormIsnumeric(strNum)
{
    var strCheckNum = strNum + "";
    if(strCheckNum.length < 1)  return false;
    else{
        if(isNaN(strCheckNum)) return false;
    }
    return true;
}


function Trim(s){
    var m = s.match(/^\s*(\S+(\s+\S+)*)\s*$/);
    return (m == null) ? "" : m[1];
}


//兼容JSDATEDIFF
function JsDateDiff(sDate1, sDate2){  //sDate1和sDate2是2002-12-18格式 目前只允许取天数
    sDate1=Trim(sDate1).split(" ")[0];
    sDate2=Trim(sDate2).split(" ")[0];
    var aDate, oDate1, oDate2, iDays;
    aDate = sDate1.split("-");
    oDate1 = new Date(aDate[1] + '/' + aDate[2] + '/' + aDate[0]);  //转换为12-18-2002格式
    aDate = sDate2.split("-");
    oDate2 = new Date(aDate[1] + '/' + aDate[2] + '/' + aDate[0]);

    iDays = parseInt((oDate2 - oDate1) / 1000 / 60 / 60 /24);  //把相差的毫秒数转换为天数
    return iDays;
}
