function trim(s) {
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
  return s;
}


function commonValidate(controlName,controlValue,minLength,maxLength,numberRequired)
{
	if(numberRequired)
	{
		if(isNaN(controlValue))
		{
			alert(controlName + "不是有效的数字!");
			return false;
		}
	}
	if(controlValue.length<minLength || controlValue.length>maxLength)
	{
		var allowTextType="字符";
		if(numberRequired)
		{
			allowTextType="数字";
		}
		alert(controlName + "必须为" + minLength + "到" + maxLength + "个" + allowTextType +"!");
		//document.all.controlName.focus();
		return false;
	}
	return true;
}
function notNullValidate(controlName,controlValue)
{
	if(controlValue==null || trim(controlValue)=="")
	{
		alert(controlName + "的值不能为空!");
		return false;
	}
	return true;
}
function telValidate(controlName,controlValue)
{
	return true;
	if(controlValue!="")
	{
	var exp=new RegExp("(((\\d{3})-(\\d{8}))|((\\d{4})-(\\d{7})))((^$)|(-d{0,10}))");	
	var matches=controlValue.match(exp);
	if(matches==null)
	{
		alert(controlName + "的值不是有效的电话号码!");
		return false;
	}
	}
	return true;
}
function postalcodeValidate(controlName,controlValue)
{
	if(controlValue!="")
	{
	var exp=new RegExp("\\d{6}");	
	var matches=controlValue.match(exp);
	if(matches==null)
	{
		alert(controlName + "的值不是有效的邮政编码!");
		return false;
	}
	}
	return true;
}
function emailValidate(controlName,controlValue)
{
	if(controlValue!="")
	{
	var exp=new RegExp("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");	
	var matches=controlValue.match(exp);
	if(matches==null)
	{
		alert(controlName + "的值不是有效的电子邮件!");
		return false;
	}
	return true;
	}
}
function websiteValidate(controlName,controlValue)
{	
	if(controlValue!="")
	{
	var exp=new RegExp("([\\w-]+\\.)+[\\w-]+(/[\\w- ./?%&=]*)?");	
	var matches=controlValue.match(exp);
	if(matches==null)
	{
		alert(controlName + "的值不是有效的网址!");
		return false;
	}
	}
}
function idCardValidate(controlName,controlValue)
{	
	if(controlValue!="")
	{
	var exp=new RegExp("\\d{18}|\\d{15}");	
	var matches=controlValue.match(exp);
	if(matches==null)
	{
		alert(controlName + "的值不是有效的身份证号!");
		return false;
	}
	return true;
	}
}
function sensitiveCharValidate(controlName,controlValue)
{
return true;
	if(controlValue!="")
	{
	var exp=new RegExp("\\d{18}|\\d{15}");	
	var matches=controlValue.match(exp);
	if(matches==null)
	{
		//alert(controlName + "的值含有非法字符!");
		return false;
	}
	}
}
function CheckPhoneName(controlName,controlValue)
{		
		var exp=new RegExp("^(((\\d{3})-(\\d{8}))|((\\d{4})-(\\d{8}))|((\\d{4})-(\\d{7}))|(\\d{12})|(\\d{11}))$");
		var matches = controlValue.match(exp);
		if(matches==null)
		{
			alert(controlName + "的格式为区号+8位或7位数字或者11到12位数字。");
			return false;
		}	
	    	return true;
}
function CheckMobileName(controlName,controlValue)
{		
		var exp=new RegExp("(^\\d{11,12})$");
		var matches = controlValue.match(exp);
		if(matches==null)
		{
			alert(controlName + "的格式11或12位数字。");
			return false;
		}	
	    	return true;
}
function CheckUserName(controlName,controlValue)
{		
		var exp=new RegExp("(\\d{11})");
		var matches = controlValue.match(exp);
		if(matches==null)
		{
			alert(controlName + "的格式11或12位数字。");
			return false;
		}	
	    	return true;
}