/*程序功能:输入验证*//*函数名称:*//*functionCheckData(valname,val,valimode,limitlen)*//*功能说明:验证字符串数据*//*functionCheckUserName(val,min,max)*//*功能说明:验证用户名*//*functionCheckPassWord(val,min,max)*//*功能说明:验证密码*//*functionIsSame(val1,val2)*//*验证密码匹配*//*functionCheckEmail(val,mode)*//*功能说明:验证Email*//*functionCheckValHeight(val,min,max,mode)*//*功能说明:验证用户身高*//*functionCheckValWeight(val,min,max,mode)*//*功能说明:验证用户体重*//*functionCheckNumber(val,min,max,mode)*//*功能说明:验证数值*//*functionCheckPositive(val,min,max,mode)*//*功能说明:验证正数值*//*functionCheckNegative(val,min,max,mode)*//*功能说明:验证负数值*//*functionCheckFloat(val,min,max,mode)*//*功能说明:验证浮点数值*//*functionCheckPath(val,mode)*//*功能说明:验证文件路径*//*functionCheckURL(val,mode)*//*功能说明:验证URL*//*functionCheckChinaIDCard_J(val,mode)*//*功能说明:验证身份证*//*functionisInteger(sNum)*//*功能说明:验证整数*//*functionCheckZip(val,slen,mode)*//*功能说明:验证Zip*//*输入参数:mode真&假(是否允许为空)*//*val表单(被判断项),va2表单(被判断项)*//*max(最大值),min(最小值)......*//*编写时间:2003.09.08.2214*//*$#################################################$*///验证字符串数据functionCheckData(valname,val,valimode,limitlen){if(val.value.indexOf(,0)0||val.value.indexOf(,0)0){alert(valname+不能包含或字符!。);val.focus();val.select();returnfalse;}if(valimode==1){if(isblank(val.value)){alert(valname+不能为空!);val.focus();val.select();returnfalse;}tmp=newString(val.value)if(istoolong(tmp,limitlen)){alert(valname+不能超过+limitlen+个字符!);val.focus();val.select();returnfalse;}}else{tmp=newString(val.value)if(istoolong(tmp,limitlen)){alert(valname+不能超过+limitlen+个字符!!);val.focus();val.select();returnfalse;}}returntrue;}functionisblank(str){vari;varlen=str.length;for(i=0;ilen;++i){if(str.charAt(i)!=)returnfalse;}returntrue;}functionistoolong(str,i){varlen=str.length;if(i==0)returnfalse;else{if(leni)returntrue;elsereturnfalse;}}//验证用户名functionCheckUserName(val,min,max){varlen=val.value.length;if(lenmin||lenmax){alert(用户名长度不正确,应为+min+-+max+个英文字母、数字。);val.focus();val.select();returnfalse;}for(i=0;ival.value.length;i++){varch=val.value.charAt(i);if((ch0||ch9)&&(cha||chz)){alert(用户名必须由小写字母或数字组成。);val.focus();val.select();returnfalse;}}varfirst=val.value.charAt(0)if(firsta||chz){alert(用户名必须由小写字母开头。);val.focus();val.select();returnfalse;}returntrue;}//验证密码functionCheckPassWord(val,min,max){varlen=val.value.length;if(lenmin||lenmax){alert(密码长度不正确,应为+min+-+max+个英文字母、数字。);val.focus();val.select();returnfalse;}for(i=0;ival.value.length;i++){varch=val.value.charAt(i);if((ch0||ch9)&&(cha||chz)){alert(密码必须由小写字母或数字组成。);val.focus();val.select();returnfalse;}}returntrue;}//验证密码匹配functionIsSame(val1,val2){if(val1.value!=val2.value){alert(两次输入的密码不相同。);val2.focus();val2.select();returnfalse;}elsereturntrue;}//验证EmailfunctionCheckEmail(val,mode){if((mode==0)&&(val.value==)){returntrue;}varetextvarelenvarivaraaetext=val.valueelen=etext.lengthif(elen5){alert(请输入正确的Email。);val.focus();val.select();returnfalse;}i=etext.indexOf(@,0)if(i==0||i==-1||i==elen-1){alert(请输入正确的Email。);val.focus();val.select();returnfalse;}else{if(etext.indexOf(@,i+1)!=-1){alert(请输入正确的Email。);val.focus();val.select();returnfalse;}}if(etext.indexOf(..,i+1)!=-1){alert(请输入正确的Email。);val.focus();val.select();returnfalse;}i=etext.indexOf(.,0)if(i==0||i==-1||etext.charAt(elen-1)=='.'){alert(请输入正确的Email。);val.focus();val.select();returnfalse;}if(etext.charAt(0)=='-'||etext.charAt(elen-1)=='-'){alert(请输入正确的Email。);val.focus();val.select();returnfalse;}if(etext.charAt(0)=='_'||etext.charAt(elen-1)=='_'){alert(请输入正确的Email。);val.focus();val.select();returnfalse;}for(i=0;i=elen-1;i++){aa=etext.charAt(i)if(!((aa=='.')||(aa=='@')||(aa=='-')||(aa=='_')||(aa='0'&&aa='9')||(aa='a'&&aa='z')||(aa='A'&&aa='Z'))){alert(请输入正确的Email。);val.focus();val.select();returnfalse;}}returntrue;}//验证用户身高functionCheckValHeight(val,min,max,mode){if((mode==0)&&(val.value==)){returntrue;}varlen=val.value.length;if(lenmin||lenmax){alert(请输入正确的身高数据。);val.focus();val.select();returnfalse;}varval2=val.value;for(i=0;ival2.length;i++){varch=val2.charAt(i);if((ch0||ch9)){alert(身高数据必须由有效数字组成。);val.focus();val.select();returnfalse;}}if(isNaN(val2)){alert(身高数据必须由有效数字组成。);val.focus();val.select();returnfalse;}elseif(parseInt(val2)=0){alert(身高数据必须由有效数字组成。);val.focus();val.select();returnfalse;}elseif(val2.indexOf('0')==0){alert(身高数据必须由有效数字组成。);val.focus();val.select();returnfalse;}returntrue;}//验证用户体重functionCheckValWeight(val,min,max,mode){if((mode==0)&&(val.value==)){returntrue;}varlen=val.value.length;if(lenmin||lenmax){alert(请输入正确的体重数据。);val.focus();val.select();returnfalse;}varval2=val.value;for(i=0;ival2.length;i++){varch=val2.charAt(i);if((ch0||ch9)){alert(体重数据必须由有效数字组成。);val.focus();val.select();returnfalse;}}if(isNaN(val2)){alert(体重数据必须由有效数字组成。);val.focus();val.select();returnfalse;}elseif(parseInt(val2)=0){alert(体重数据必须由有效数字组成。);val.focus();val.select();returnfalse;}elseif(val2.indexOf('0')==0){alert(体重数据必须由有效数字组成。);val.focus();val.select();returnfalse;}returntrue;}//验证数值functionCheckNumber(val,min,max,mode){if((mode==0)&&(val.value==)){returntrue;}va