// JavaScript Document
	function checkValue(str){			//检测文本框的输入内容是不是合法
		var notAllowStr="<,>,',`,^,&";		//不允许输入的字符,使用","隔开
		var rtn=true;
		var notAllowArr=new Array();
		notAllowArr=notAllowStr.split(",");
		for(var i=0;i<notAllowArr.length;i++){
			if(str.indexOf(notAllowArr[i])!=-1){
					rtn=false;
			}
		}
		return rtn;
	}//end checkValue
	//验证一个日期的合法性.不是很完善
	function checkDate(str){
		if(checkValue(str)!=true){
			alert("请勿使用敏感字符!!!");
			return false;	
		}
		var dateReg=/^[0-9]{4,4}(-|\/)[0-9]{2,2}(-|\/)[0-9]{2,2}$/;		//建立日期正刚表达式
		//alert(regStr(dateReg,str));
		return dateReg.test(str);
	}
	//验证一个生份证号码的完全性
	function checkIndCard(str){
		if(checkValue(str)!=true){
			alert("请勿使用敏感字符!!!");
			return false;	
		}
		var cardReg=/^(\d{8}(01|02|03|04|05|06|07|08|09|10|11|12)(01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31)\d{3}|\d{6}(19|20)\d{2}(01|02|03|04|05|06|07|08|09|10|11|12)(01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31)\d{3}(\d|X))$/;		//建立生份证的正则表达式
		return cardReg.test(str);
	}
	/*验证邮编*/
	function checkZip(str){
		if(checkValue(str)!=true){
			alert("请勿使用敏感字符!!!");
			return false;	
		}
		var zipReg=/^[0-9]{6,6}$/;		//建立生份证的正则表达式
		return zipReg.test(str);
	}
	/*验证Email格式*/
	function checkEmail(str){
		if(checkValue(str)!=true){
			alert("请勿使用敏感字符!!!");
			return false;	
		}
		var emailReg=/^(\S)+[@]{1}(\S)+[.]{1}(\w)+$/;		//建立Email正则表达式
		//alert(regStr(dateReg,str));
		return emailReg.test(str);
	}
	function checkUrl(str){
		if(checkValue(str)!=true){
			alert("请勿使用敏感字符!!!");
			return false;	
		}
		var urlReg=/^[a-zA-z]+:\/\/(\w+(-\w+)*)(\.(\w+(-\w+)*))*(\?\S*)?$/;
		return urlReg.test(str);
	}
		function checkTel(str){
		if(checkValue(str)!=true){
			alert("请勿使用敏感字符!!!");
			return false;	
		}
		var telReg=/^[0-9|-]{6,12}$/;
		return telReg.test(str);
	}
	/*去除字符两边的空格*/
	function killspace(str){
		while(str.length>0 && str.charAt(0)==" ")
			str=str.substring(1,str.length);
		while(str.length>0&&str.charAt(str.length-1)==" ")
			str=str.substring(0,str.length-1);
		return str;		
	}
	/*函数使用:验证一个字符在另一个字符串中最多出现的次数*/
	/*
		参数str:要检测的字符串
		参数char:要检测的字符
		参数times:最多出现次数
	*/
		function checkTimes(str,char,times){
		var findTimes=0;
		for(var i=0;i<str.length;i++){
			if(str.charAt(i)==char){
				findTimes+=1
			}
		}
		if(findTimes>times){
			return false;
		}else{
			return true;
		}
	}
	
/*
'函数作用:验证输入法数据的合法性
'使用方法onkeypress	= "return regInput(this,	/^\d*\.?\d{0,2}$/,		String.fromCharCode(event.keyCode))"
*/
	function regInput(obj, reg, inputStr){
			var docSel	= document.selection.createRange()
			if (docSel.parentElement().tagName != "INPUT")	return false
			oSel = docSel.duplicate()
			oSel.text = ""
			var srcRange	= obj.createTextRange()
			oSel.setEndPoint("StartToStart", srcRange)
			var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length)
			return reg.test(str)
	}

