欢迎来到天天文库
浏览记录
ID:17429423
大小:44.00 KB
页数:17页
时间:2018-08-31
《js表单判断函数代码大全》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、JS表单判断函数代码大全JS表单判断函数代码大全}returntrue;}//验证负数值functionCheckNegative(val,min,max,mode){if((mode==0)&&(val.value=="")){returntrue;}if(!CheckNumber(val,min,max,mode)){val.focus();val.select();returnfalse;}if(parseInt(val.value)>=0){alert("数据必须为有效的负整数。");val.focus();
2、val.select();returnfalse;}returntrue;}//验证浮点数值functionCheckFloat(val,min,max,mode){if((mode==0)&&(val.value=="")){returntrue;}varlen=val.value.length;if(len3、4、len>max){alert("请输入正确的浮点数值。");val.focus();val.select();returnfalse;}varval2=val.value;for(i=1;i5、2.length;i++){varch=val2.charAt(i);if((ch<"0"6、7、ch>"9")){if(ch!="."){alert("请输入正确的浮点数值。");val.focus();val.select();returnfalse;}}}if(isNaN(val2)){alert("请输入正确的浮点数值。");val.focus();val.select();returnfalse;}elseif(val2.indexOf('0')==0&&val2.indexOf('.')!=1){alert(8、"请输入正确的有效浮点数值。");val.focus();val.select();returnfalse;}elseif(val2.indexOf('-')==0&&val2.indexOf('0')==1&&val2.indexOf('.')!=2){alert("请输入正确的有效浮点数值。");val.focus();val.select();returnfalse;}elseif(val2.indexOf('-')==0&&val2.indexOf('.')==1){alert("请输入正确的有效浮点数值。"9、);val.focus();val.select();returnfalse;}elseif(val2.indexOf('.')==0){alert("请输入正确的有效浮点数值。");val.focus();val.select();returnfalse;}returntrue;}//验证文件路径functionCheckPath(val,mode){if((mode==0)&&(val.value=="")){returntrue;}varval2=val.value;if(val2.indexOf(':\')10、>0){varisNot="!@#$^*()'`~11、]}[{;.>,%&+=";if(val2.indexOf('"')>0){alert("请输入正确的文件路径。");val.focus();val.select();returnfalse;}else{for(vari=0;i12、val.select();returnfalse;}}}}}else{alert("请输入正确的文件路径。");val.focus();val.select();returnfalse;}returntrue;}//验证URLfunctionCheckURL(val,mode){if((mode==0)&&(val.value=="")){returntrue;}varval2=val.value;if(val2.indexOf('://')>0){varisNot="!@$^*()'`~13、]}[{;.>,<";if14、(val2.indexOf('"')>0){alert("请输入正确的URL。");val.focus();val.select();returnfalse;}else{for(vari=0;i
3、
4、len>max){alert("请输入正确的浮点数值。");val.focus();val.select();returnfalse;}varval2=val.value;for(i=1;i5、2.length;i++){varch=val2.charAt(i);if((ch<"0"6、7、ch>"9")){if(ch!="."){alert("请输入正确的浮点数值。");val.focus();val.select();returnfalse;}}}if(isNaN(val2)){alert("请输入正确的浮点数值。");val.focus();val.select();returnfalse;}elseif(val2.indexOf('0')==0&&val2.indexOf('.')!=1){alert(8、"请输入正确的有效浮点数值。");val.focus();val.select();returnfalse;}elseif(val2.indexOf('-')==0&&val2.indexOf('0')==1&&val2.indexOf('.')!=2){alert("请输入正确的有效浮点数值。");val.focus();val.select();returnfalse;}elseif(val2.indexOf('-')==0&&val2.indexOf('.')==1){alert("请输入正确的有效浮点数值。"9、);val.focus();val.select();returnfalse;}elseif(val2.indexOf('.')==0){alert("请输入正确的有效浮点数值。");val.focus();val.select();returnfalse;}returntrue;}//验证文件路径functionCheckPath(val,mode){if((mode==0)&&(val.value=="")){returntrue;}varval2=val.value;if(val2.indexOf(':\')10、>0){varisNot="!@#$^*()'`~11、]}[{;.>,%&+=";if(val2.indexOf('"')>0){alert("请输入正确的文件路径。");val.focus();val.select();returnfalse;}else{for(vari=0;i12、val.select();returnfalse;}}}}}else{alert("请输入正确的文件路径。");val.focus();val.select();returnfalse;}returntrue;}//验证URLfunctionCheckURL(val,mode){if((mode==0)&&(val.value=="")){returntrue;}varval2=val.value;if(val2.indexOf('://')>0){varisNot="!@$^*()'`~13、]}[{;.>,<";if14、(val2.indexOf('"')>0){alert("请输入正确的URL。");val.focus();val.select();returnfalse;}else{for(vari=0;i
5、2.length;i++){varch=val2.charAt(i);if((ch<"0"
6、
7、ch>"9")){if(ch!="."){alert("请输入正确的浮点数值。");val.focus();val.select();returnfalse;}}}if(isNaN(val2)){alert("请输入正确的浮点数值。");val.focus();val.select();returnfalse;}elseif(val2.indexOf('0')==0&&val2.indexOf('.')!=1){alert(
8、"请输入正确的有效浮点数值。");val.focus();val.select();returnfalse;}elseif(val2.indexOf('-')==0&&val2.indexOf('0')==1&&val2.indexOf('.')!=2){alert("请输入正确的有效浮点数值。");val.focus();val.select();returnfalse;}elseif(val2.indexOf('-')==0&&val2.indexOf('.')==1){alert("请输入正确的有效浮点数值。"
9、);val.focus();val.select();returnfalse;}elseif(val2.indexOf('.')==0){alert("请输入正确的有效浮点数值。");val.focus();val.select();returnfalse;}returntrue;}//验证文件路径functionCheckPath(val,mode){if((mode==0)&&(val.value=="")){returntrue;}varval2=val.value;if(val2.indexOf(':\')
10、>0){varisNot="!@#$^*()'`~
11、]}[{;.>,%&+=";if(val2.indexOf('"')>0){alert("请输入正确的文件路径。");val.focus();val.select();returnfalse;}else{for(vari=0;i12、val.select();returnfalse;}}}}}else{alert("请输入正确的文件路径。");val.focus();val.select();returnfalse;}returntrue;}//验证URLfunctionCheckURL(val,mode){if((mode==0)&&(val.value=="")){returntrue;}varval2=val.value;if(val2.indexOf('://')>0){varisNot="!@$^*()'`~13、]}[{;.>,<";if14、(val2.indexOf('"')>0){alert("请输入正确的URL。");val.focus();val.select();returnfalse;}else{for(vari=0;i
12、val.select();returnfalse;}}}}}else{alert("请输入正确的文件路径。");val.focus();val.select();returnfalse;}returntrue;}//验证URLfunctionCheckURL(val,mode){if((mode==0)&&(val.value=="")){returntrue;}varval2=val.value;if(val2.indexOf('://')>0){varisNot="!@$^*()'`~
13、]}[{;.>,<";if
14、(val2.indexOf('"')>0){alert("请输入正确的URL。");val.focus();val.select();returnfalse;}else{for(vari=0;i
此文档下载收益归作者所有