//检测时间格式是否为1999-02-02这种格式
function CheckDateTime(InputValue) {
	//检测时间格式是否为1999-02-02或2003/9/3这种格式
		
	var reg=/^(19|20)\d{2}[\-](0[1-9]|1[0-2])[\-](0[1-9]|[12][0-9]|3[01])$/
	var isValid
		
		isValid=reg.exec(InputValue)
		if (!isValid) {
			//alert("输入 "+InputValue+" 无效！")
			return false
		}
		return true
}

// 检测时间格式是否为1999-01
function CheckYearMonth(InputValue) {
    var reg=/^(19|20)\d{2}[\-](0[1-9]|1[0-2])$/
	var isValid
		
		isValid=reg.exec(InputValue)
		if (!isValid) {
			//alert("输入 "+InputValue+" 无效！")
			return false
		}
		return true
}

// 检测时间格式是否为1999
function CheckYear(InputValue) {
    var reg=/^(19|20)\d{2}$/
	var isValid
		
		isValid=reg.exec(InputValue)
		if (!isValid) {
			//alert("输入 "+InputValue+" 无效！")
			return false
		}
		return true
}


// 检测是否只输入字母和数字(不包括中文)，而且不允许为空
function CheckLetterNum(InputValue){
    var reg=/^([a-z]|[A-Z]|[0-9])+$/
	var isValid
		
		isValid=reg.exec(InputValue)
		if (!isValid) {
			//alert("输入 "+InputValue+" 无效！")
			return false
		}
		return true
}

// 检测是否输入了导致错误的字符，如"'"等,可以输入中文，允许为空
function CheckErrorInput(InputValue){
    var reg=/^(([^'"~!@#$%^&*(){}:;,/?`])*)$/
	var isValid
		
		isValid=reg.exec(InputValue)
		if (!isValid) {
			//alert("输入 "+InputValue+" 无效！")
			return false
		}
		return true
}

// 只允许输入数字，而且不允许为空
function CheckNum(InputValue){
    var reg=/^([0-9])+$/
	var isValid
		
		isValid=reg.exec(InputValue)
		if (!isValid) {
			//alert("输入 "+InputValue+" 无效！")
			return false
		}
		return true
}

// 只允许输入数字，而且允许为空
function CheckNullNum(InputValue){
    var reg=/^([0-9])*$/
	var isValid
		
		isValid=reg.exec(InputValue)
		if (!isValid) {
			//alert("输入 "+InputValue+" 无效！")
			return false
		}
		return true
}


// 检测MONEY的输入
function CheckMoney(InputValue){
    var reg=/^([0-9]+)[.]{0,1}([0-9]{0,2})$/
	var isValid
		
		isValid=reg.exec(InputValue)
		if (!isValid) {
			//alert("输入 "+InputValue+" 无效！")
			return false
		}
		return true
}

//检测时间格式是否为12:23这种格式
function CheckTime(InputValue) {
	//检测时间格式是否为12:23或12：23这种格式
		
	var reg=/^(((0[0-9]|1[0-9]|2[0-3])([\:]|[\：])([0-5][0-9]|60))|[2][4]([\:]|[\：])[0][0])$/
	var isValid
		

		isValid=reg.exec(InputValue)
		if (!isValid) {
			//alert("输入 "+InputValue+" 无效！")
			return false
		}
		return true
}

//检测IP格式是否为xxx.xxx.xxx.xxx这种格式
function CheckIP(InputValue) {
		
	var reg=/^((([1-2]?[0-9]?[0-9])[\.]){3})([1-2]?[0-9]?[0-9])$/
	var isValid
		

		isValid=reg.exec(InputValue)
		if (!isValid) {
			//alert("输入 "+InputValue+" 无效！")
			return false
		}
		return true
}

// 去除首尾空格
function Trim(str) {
	
	blnbeginflag=true
	blnendflag=true
	     
	for (i=0;i<str.length;i++) {           
			if ((str.indexOf(" ")==0) && blnbeginflag){			
			    intlen=str.length				  	 
			    str=str.substring(1,intlen)			 
			    i--			    
			}else{
			    blnbeginflag=false
			}
			
			if ((str.lastIndexOf(" ")==(str.length-1)) && blnendflag) {			
			    str=str.substring(0,str.length-1)			    
			}else{
			    blnendflag=false
			}
         }
         
         return str
}
// 判断TEXTAREA中的文字个数不得超过255个；中文，英文都只占一个字符
function CheckLength(textarea,length) {
	intLength=(Trim(textarea.value)).length
		
	if (intLength>length) {
		alert("请不要输入超过"+length+"个字符！")
		textarea.focus()
		textarea.select()
		return false
	}
	return true
}

// Function to check an email address.
function checkEmail(email) {

  var re = /\w+@\w+\.\w+/;
  if (re.test(email))
    return true;
  else
    return false;
}