function DelSpace(str){	var splitString;splitString = str.split(" ");return splitString.join(""); }
function IsNR(str){return(DelSpace(str)!="")&&(!(isNaN(str)))}
function IsNP(str){return(DelSpace(str)!="")&&(!(isNaN(str)))&&(DelSpace(str).charAt(0)!="-")&&(DelSpace(str).charAt(0)!="0")}
function IsNI(str){return(DelSpace(str)!="")&&(!(isNaN(str)))&&(str.indexOf(".")==-1)}
function IsNN(str){return(DelSpace(str)!="")&&(!(isNaN(str)))&&(str.indexOf(".")==-1)&&(DelSpace(str).charAt(0)!="-")&&(DelSpace(str).charAt(0)!="0")}
function DateIsNotNum(str){return(DelSpace(str)!="")&&(isNaN(str))||(str.indexOf(".")!=-1)||(DelSpace(str).charAt(0)=="-")}
function CheckDate(strYear,strMonth,strDay)
{	var year = strYear;var month = strMonth;var day = strDay;
	if(parseInt(year)<=1900||parseInt(year)>2100||year.length<4||DateIsNotNum(year)){return(1)}
	if(parseInt(month)+100<=100|| month.length<1||parseInt(month)+100>112||DateIsNotNum(month)) { return (2) }
	if (parseInt(day)<=0||day.length<1||parseInt(day)>31||DateIsNotNum(day)){return(3)}
	if(parseInt(month)==2&&parseInt(day)>29){return(3)}
	if((year/4)!=Math.round(year/4)&&month==2&&day>28){return(3)}
	if((year/400)!=Math.round(year/400)&&(year/100)==Math.round(year/100)&&month==2&&day>28){return(3)}
	if((month==4&&day==31)||(month==6&&day==31)||(month==9&&day==31)||(month==11&&day==31)){return(3)}
	return 0;}
function CheckTime(strH,strM,strS)
{if(parseInt(strH)<0||parseInt(strH)>23||DateIsNotNum(strH)){return(1)}
if(parseInt(strM)<0||parseInt(strM)>59||DateIsNotNum(strM)){return(2)}
if(parseInt(strS)<0||parseInt(strS)>59||DateIsNotNum(strS)){return(3)}
return 0;}
function IsString(str){if(DelSpace(str)!=""){return true}return false;}
function IsEmail(str){if(str.match("^[^@]+@([a-zA-Z0-9\-]+[\.])+([a-zA-Z0-9\-])")){return true}return false;}
function IsNSpace(str){if((DelSpace(str)!="")&&(str.indexOf(" ")==-1)){return true}return false;}
function CheckCh(formName,elementName){var j;if((document.forms(formName)(elementName).length>0)==false){if(document.forms(formName)(elementName).checked==true){return true}return false}else{for (j=0;j<document.forms(formName)(elementName).length;j++){ if(document.forms(formName)(elementName)[j].checked==true){return true}}return false;}}
function CheckRd(formName,elementName){var j;if((document.forms(formName)(elementName).length>0)==false){if(document.forms(formName)(elementName).checked==true){return true}return false}else{for(j=0;j<document.forms(formName)(elementName).length;j++){if(document.forms(formName)(elementName)[j].checked==true){return true}}return false}}
function CheckSl(formName,elementName){	if (document.forms(formName)(elementName).selectedIndex==0){return false}return true}
function CheckTx(str){if(DelSpace(str)!=""){return true}return false}
function ErrorFind(formName,elementsIndex,errorMsg){window.alert(errorMsg);document.forms(formName).elements[elementsIndex].focus();return false;}
function DateErrorFind(formName,yearName,monthName,dayName,errorNum,errStr){switch (errorNum){case 1:{window.alert("请输入正确的"+errStr+"年份!");document.forms(formName)(yearName).focus();return false;break;}case 2:{window.alert("请输入正确的"+errStr+"月份!");document.forms(formName)(monthName).focus();return false;break;}case 3:{window.alert("请输入正确的"+errStr+"日期!");document.forms(formName)(dayName).focus();return false;break;}}}
function TimeErrorFind(formName,yearName,monthName,dayName,errorNum){switch (errorNum){case 0:{return true;break;}case 1:{window.alert("请输入正确的小时数!");document.forms(formName)(yearName).focus();return false;break;}case 2:{window.alert("请输入正确的分钟数!");document.forms(formName)(monthName).focus();return false;break;}case 3:{window.alert("请输入正确的秒数!");document.forms(formName)(dayName).focus();return false;break;}}}
function CheckInput(formName)
{	var tempFormName;var tempArr;var i;var tempCheckString;tempFormName=formName;i=0;
	vlu='document.forms(tempFormName).elements[i].value'
	ele='document.forms(tempFormName).elements[i].';
	fms='document.forms(tempFormName)'
	for (i=0;i<eval(fms+'.length');i++)
	{	tempArr = eval(ele+'id.split(\"_\")');
		switch (eval(ele+'type'))
		{	case "text":
			{	tempCheckString="";
				if (("se-sn-ss-d1-d2-d3-nr-np-ni-nn-t1").indexOf(tempArr[1])!=-1){tempCheckString = tempArr[1]}else{tempNeedCheck=""}
				if ((("SE-SN-SS-D1-D2-D3-NR-NP-NI-NN-T1").indexOf(tempArr[1])!=-1)&&(DelSpace(eval(vlu))!="")){tempCheckString = tempArr[1].toLowerCase()}else{tempNeedCheck=""}
				switch(tempCheckString)
				{	case "se":{if(!(IsEmail(eval(vlu)))){return ErrorFind(tempFormName,i,"请检查"+tempArr[0]+"是否输入正确!")}break;}
					case "sn":{if(!(IsString(eval(vlu)))){return ErrorFind(tempFormName,i,"请输入"+tempArr[0]+"!")}break;}
					case "ss":{if(!(IsNSpace(eval(vlu)))){return ErrorFind(tempFormName,i,tempArr[0]+"不能有空格!")}break;}
					case "d1":{var tempValue;tempValue=CheckDate(eval(fms+'(tempArr[2]).value'),eval(fms+'(tempArr[3]).value'),eval(fms+'(tempArr[4]).value'));if(tempValue > 0){return DateErrorFind(tempFormName,tempArr[2],tempArr[3],tempArr[4],tempValue,tempArr[0])}break;}
					case "d2":{var tempValue;tempValue=CheckDate(eval(fms+'(tempArr[2]).value'),eval(fms+'(tempArr[3]).value'),"1");if(tempValue > 0){return DateErrorFind(tempFormName,tempArr[2],tempArr[3],tempArr[4],tempValue,tempArr[0])}break;}
					case "d3":{var tempValue;tempValue=CheckDate(eval(fms+'(tempArr[2]).value'),"1","2");if(tempValue > 0){return DateErrorFind(tempFormName,tempArr[2],tempArr[3],tempArr[4],tempValue,tempArr[0])}break;}
					case "nr":{if((DelSpace(eval(vlu))=="")||!(IsNR(eval(vlu)))){return ErrorFind(tempFormName,i,"您输入的"+tempArr[0]+"不是一个数值!") }break;}
					case "np":{if((DelSpace(eval(vlu))=="")||!(IsNP(eval(vlu)))){return ErrorFind(tempFormName,i,"您输入的"+tempArr[0]+"不是一个正数!")}break;}
					case "ni":{if((DelSpace(eval(vlu))=="")||!(IsNI(eval(vlu)))){return ErrorFind(tempFormName,i,"您输入的"+tempArr[0]+"不是一个整数!")}break;}
					case "nn":{if((DelSpace(eval(vlu))=="")||!(IsNN(eval(vlu)))){return ErrorFind(tempFormName,i,"您输入的"+tempArr[0]+"不是一个正整数!")}break;}
					case "t1":{return TimeErrorFind(tempFormName,tempArr[2],tempArr[3],tempArr[4],CheckTime(eval(fms+'(tempArr[2]).value'),eval(fms+'(tempArr[3]).value'),eval(fms+'(tempArr[4]).value')));break;}
				}
				break;
			}
			case "checkbox":{if(tempArr[1]=="ch"){if(!(CheckCh(tempFormName,eval(ele+'name')))){return ErrorFind(tempFormName,i,"请选择"+tempArr[0]+"!")}}break;}
			case "radio":{if(tempArr[1]=="rd"){if(!(CheckRd(tempFormName,eval(ele+'name')))){return ErrorFind(tempFormName,i,"请选择"+tempArr[0]+"!")}}break;}
			case "select-one":{if(tempArr[1]=="sl"){if(!(CheckSl(tempFormName,eval(ele+'name')))){return ErrorFind(tempFormName,i,"请选择"+tempArr[0]+"!")}}break;}
			case "textarea":{if(tempArr[1]=="tx"){if(!(CheckTx(eval(vlu)))){return ErrorFind(tempFormName,i,"请输入"+tempArr[0]+"!")}}break;}
			case "password":
			{	timpCheckString="";
				if (("pw-pwd").indexOf(tempArr[1])!=-1){tempCheckString = tempArr[1]}else{tempNeedCheck=""}
				switch(tempCheckString)
				{	case "pw":{if(tempArr[1]=="pw"){if(eval(fms+'.'+tempArr[2]+'.value')!=eval(fms+'.'+tempArr[3]+'.value')){return ErrorFind(tempFormName,i,"请输入相同的密码和确认密码!")}}break}
					case "pwd":{if(!(IsString(eval(vlu)))){return ErrorFind(tempFormName,i,"请输入"+tempArr[0]+"!")}break;}
				}
			}
			break;
		}
	}
	return true;
}