﻿function CheckTp(tel)//检查电话号码格式的js方法
{
    if(tel.length != 7 && tel.length != 8 && tel.length != 11 && tel.length != 12 && tel.length != 13)
    {
	    return false;
    }
    else
    {
	    if(tel.length == 7 || tel.length == 8)
	    {
		    for(i=0;i<tel.length;i++)
		    {
			    if(tel.charAt(i) < "0" || tel.charAt(i) > "9")
			    {
				    return false;
			    }
		    }
		    return true;
	    }
	    if(tel.length == 11)
	    {
		    var falg = true;
		    for(i=0;i<tel.length;i++)
		    {
			    if(tel.charAt(i) < "0" || tel.charAt(i) > "9")
			    {
				    falg = false;
			    }
		    }
		    if(falg)
		    {
			    return true;
		    }
		    else
		    {
			    if(tel.charAt(3) != "-")
			    {
				    return false;
			    }
			    else
			    {
				    for(i=0;i<3;i++)
				    {
					    if(tel.charAt(i) < "0" || tel.charAt(i) > "9")
					    {
						    return false;
					    }
				    }
				    for(i=4;i<tel.length;i++)
				    {
					    if(tel.charAt(i) < "0" || tel.charAt(i) > "9")
					    {
						    return false;
					    }
				    }
			    }
		    }
		    return true;
	    }
	    if(tel.length == 12)
	    {
		    if(tel.charAt(3) != '-' && tel.charAt(4) != '-')
		    {
			    return false;
		    }
		    else
		    {
			    if(tel.charAt(3) == '-')
			    {
				    for(i=0;i<3;i++)
				    {
					    if(tel.charAt(i) < "0" || tel.charAt(i) > "9")
					    {
						    return false;
					    }
				    }
				    for(i=4;i<tel.length;i++)
				    {
					    if(tel.charAt(i) < "0" || tel.charAt(i) > "9")
					    {
						    return false;
					    }
				    }
			    }
			    else
			    {
				    for(i=0;i<4;i++)
				    {
					    if(tel.charAt(i) < "0" || tel.charAt(i) > "9")
					    {
						    return false;
					    }
				    }
				    for(i=5;i<tel.length;i++)
				    {
					    if(tel.charAt(i) < "0" || tel.charAt(i) > "9")
					    {
						    return false;
					    }
				    }
			    }
		    }
		    return true;
	    }
	    if(tel.length == 13)
	    {
		    if(tel.charAt(4) != '-')
		    {
			    return false;
		    }
		    else
		    {
			    for(i=0;i<4;i++)
			    {
				    if(tel.charAt(i) < "0" || tel.charAt(i) > "9")
				    {
					    return false;
				    }
			    }
			    for(i=5;i<tel.length;i++)
			    {
				    if(tel.charAt(i) < "0" || tel.charAt(i) > "9")
				    {
					    return false;
				    }
			    }
		    }
		    return true;
	    }
    }
}


function CheckPc(pc)//检查邮政编码格式的js方法
{
    if(pc.length == 6)
    {
        for(i=0;i<pc.length;i++)
        {
            if(pc.charAt(i) < "0" || pc.charAt(i) > "9")
            {
                return false;
            }
        }
        return true;
    }
    else
    {
        return false;
    }
}

function CheckDateTime(dt)//检查日期格式的正则表达式js方法，只验证××××－××－××日期格式
{
    re = /^((((((0[48])|([13579][26])|([2468][048]))00)|([0-9][0-9]((0[48])|([13579][26])|([2468][048]))))-02-29)|(((000[1-9])|(00[1-9][0-9])|(0[1-9][0-9][0-9])|([1-9][0-9][0-9][0-9]))-((((0[13578])|(1[02]))-31)|(((0[1,3-9])|(1[0-2]))-(29|30))|(((0[1-9])|(1[0-2]))-((0[1-9])|(1[0-9])|(2[0-8]))))))$/i;
    if (re.test(dt))
    {
        return true;
    }
    else
    {
        return false;
    }
}

function CheckNumber(Number)//检查数值格式js方法，验证是否是int的数值型
{
     for(i=0;i<Number.length;i++)
        {
            if(Number.charAt(i) < "0" || Number.charAt(i) > "9")
            {
                return false;
            }
        }
     return true;  
}



function jsTrim(str)//去掉字符串的左右空格
{                
      str = str.replace(/^\s*/g,"");
      str = str.replace(/\s*$/g,"");
      return str
}