<script language="javascript">
<!--
	function validate(element, elementname, minlength, maxlength){
		var theStringLength =element.value.length
		if(theStringLength<minlength || theStringLength>maxlength){
			if(minlength=0)
				alert(elementname+"的长度不能大于"+maxlength);
			else{
				if(minlength=1)
					alert(elementname+"不能为空或长度不能大于"+maxlength);
				else
					alert(elementname+"的长度不能小于"+minlength+"或大于"+maxlength);
				}
			element.select();
			element.focus();
			return false;
		}else 
			return true;
	}

	function validateEmail(element){
		if((element.value.indexOf('@', 0)==-1)&&(element.value.length>0)){
			alert("请输入正确的Email地址。");
			element.select();
			element.focus();		
		 	return false;
		}
		return true;
	}
	
	function validatePassword(element1,element2){
		if(element1.value!=element2.value){
			alert("密码与确认密码不一致!");
			element1.select();
			element1.focus();		
		 	return false;
		}
		return true;
	}
	
	function validateCode(element,elementname)
	{  
	   var strelement=element.value;
	   var theStringLength =element.value.length
	   
	   for (var i=0;i<theStringLength;i++)
	   {
	     var inttmp=strelement.charCodeAt(i);
	     if (inttmp>126)
	     {
	      alert(elementname+"中有无效字符!");
	      element.select();
		  element.focus();
		  return false;
		 }
	   }
		return true;
	}

	function validateNumber(element,elementname)
	{  
	   var strelement=element.value;
	   var theStringLength =element.value.length
	   
	   for (var i=0;i<theStringLength;i++)
	   {
	     var inttmp=strelement.charCodeAt(i);
	     if ((inttmp<48 || inttmp>57) && (inttmp!=46))
	     {
	      alert(elementname+"中必须是数字!");
	      element.select();
		  element.focus();
		  return false;
		 }
	   }
		return true;
	}

	function validateTelephoneCode(element,elementname)
	{  
	   var strelement=element.value;
	   var theStringLength =element.value.length
	   
	   for (var i=0;i<theStringLength;i++)
	   {
	     var inttmp=strelement.charCodeAt(i);
	     if ((inttmp<48 || inttmp>57) && (inttmp!=45) && (inttmp!=40) && (inttmp!=41) && (inttmp!=32))
	     {
	      alert(elementname+"格式不对!");
	      element.select();
		  element.focus();
		  return false;
		 }
	   }
		return true;
	}
	
	function validateSelect(element,elementname,noselect)
	{
		if (element.value==noselect)
			{
			alert("请选择"+elementname+"!");
			element.focus();
			return false;
			}
		else
			return true;
	}
//-->
</script>
