
<!--
/********www.2-matrix.com*************/
/**********version:1.0****************/
function Trim(str){ //去除str变量首尾的空格。
trimlen = 0
	for(i=0;i<str.length;i++){
		if (str.charAt(i)!=" "){
		break;
		}else{
		trimlen +=1 		
		}
	}
	str = str.substring(trimlen);
	trimlen = 0
	strlen = str.length-1
	for (j=strlen;j>0;j--){
		if (str.charAt(j)!=" "){		
		break;
		}else{
		trimlen +=1 
		}
	}	
	strlen = str.length-trimlen
	str = str.substring(0,strlen);
return str;
}

function checkEmpty(cheobj){   //是否为空
cheVal = Trim(cheobj.value)
if (cheVal == null||Trim(cheVal)==""){
	return false;
		}
		return true;
	}

function isEmpty(cheobj,msgname){   //是否为空
cheVal = Trim(cheobj.value)
if (cheVal == null||Trim(cheVal)==""){
	errormsg += "-\""+msgname+"\"不能为空。\n"
		}
		return true;
	}
	

function isEmail(cheobj,msgname){
	cheVal = Trim(cheobj.value)
var re = /^[\w\._-]+@([0-9a-z][\w-]+\.)+[a-zA-Z]{2,3}$/i
	if (re.test(cheVal)){
	return true;
	}else{
	errormsg += "-\""+msgname+"\"必须是正确的E-mail格式。\n";
	}
}

function isUrl(cheVal){
var re = /^[a-zA-Z]{3,4}:\/\/((\w)+\.[\w\._\/-]*)[=&\?\S*]*$/
var re1 = /^[a-zA-Z]{3,4}:\/\/$/
if (re.test(cheVal)){
	return true;
	}else{
		if (!re1.test(cheVal)){
		urlError ="-网址前请加上\'http:\/\/\'\n" 
		//alert(urlError)
		}		
	return false;
	}
}

function isNumber(cheobj,msgname){   //判别是否纯数字
cheVal = Trim(cheobj.value)
 var re = /^(\d)+$/
	if (re.test(cheVal)){
	return true;
	}else{
	errormsg += "-\""+msgname+"\"必须是数字。\n"
	}
}

function isInteger(cheobj,msgname){   //判别是否整数
cheVal = Trim(cheobj.value)
 var re = /^-?(\d)+$/
	if (re.test(cheVal)){
	return true;
	}else{
	errormsg += "-\""+msgname+"\"必须是数字。\n"
	}
}

function isFloating(cheobj,msgname){   //判别是否浮点数
cheVal = Trim(cheobj.value)
 var re = /^-?(\d)+(\.?(\d)+)?$/
	if (re.test(cheVal)){
	return true;
	}else{
	errormsg += "-\""+msgname+"\"必须是数字。\n"
	}
}

function isTel(cheobj,msgname){   //判别是否电话号码格式！
cheVal = Trim(cheobj.value)
var re = /^[\d\.\*\(\)-]*(\d){4,15}$/
	if (re.test(cheVal)){
	return true;
	}else{
	errormsg += "-\""+msgname+"\"必须是正确的电话格式。\n"
	}
}

function isDate(cheVal){   //判断是否是日期格式
//注意：日期的格式中，年份必须是4位！
cheVal = new  String(cheVal)
var re = /^(9)*$/
//cheVal.replace(/^[\*\/\,\-\#]$/,"-")
cheVal2 = cheVal.replace(re,"-")
alert(cheVal2)


/*cheArray = new Array("-",",","/","&")
for (i=0;i<cheArray.length;i++)	{
	cheStart = 0;
	cheB = 0;	
	do{		
		var cheStart = cheVal.indexOf(cheArray[i],cheStart);
		cheStart += 1;
		cheB += 1;
	if (cheB>2) return  false	
	}while(cheStart != -1)
		for (i=0;i<cheB;i++){
		cheVal = cheVal.replace(cheArray[i],"-")
		}
}
alert(cheVal);*/
}

//-->
