首页 > 资讯 > 网站设计
js 几种常用的表单输入判断
发布时间:2005-02-01   浏览次数:1151068
//函数名:chksafe//功能介绍:检查是否含有"",\\,"/"//参数说明:要检查的字符串//返回值:0:是 1:不是 function chksafe(a){ return 1;/* fibdn = new Array ("" ,"\\", "、", ",", ";", "/");i=fibdn.length;j=a.length;for (ii=0;ii0){return 1;}}}return 0;}//opt1 小数 opt2 负数//当opt2为1时检查num是否是负数//当opt1为1时检查num是否是小数//返回1是正确的,0是错误的function chknbr(num,opt1,opt2){var i=num.length;var staus;//staus用于记录.的个数status=0;if ((opt2!=1) && (num.charAt(0)==-)){//alert("You have enter a invalid number.");return 0;}//当一位为.时出错if (num.charAt(i-1)==.){//alert("You have enter a invalid number.");return 0;} for (j=0;j1) {//alert("You have enter a invalid number.");return 0; }if (num.charAt(j)9 ){if (((opt1==0) || (num.charAt(j)!=.)) && (j!=0)) {//alert("You have enter a invalid number.");return 0;}}}return 1;}//函数名:chkdate//功能介绍:检查是否为日期//参数说明:要检查的字符串//返回值:0:不是日期 1:是日期 function chkdate(datestr){var lthdatestrif (datestr != "")lthdatestr= datestr.length ;elselthdatestr=0;var tmpy="";var tmpm="";var tmpd="";//var datestr;var status;status=0;if ( lthdatestr== 0)return 0 for (i=0;i2){//alert("Invalid format of date!");return 0;}if ((status==0) && (datestr.charAt(i)!=-)){tmpy=tmpy+datestr.charAt(i)}if ((status==1) && (datestr.charAt(i)!=-)){tmpm=tmpm+datestr.charAt(i)}if ((status==2) && (datestr.charAt(i)!=-)){tmpd=tmpd+datestr.charAt(i)} }year=new String (tmpy);month=new String (tmpm);day=new String (tmpd)//tempdate= new String (year+month+day);//alert(tempdate);if ((tmpy.length!=4) || (tmpm.length>2) || (tmpd.length>2)){//alert("Invalid format of date!");return 0;}if (!((1=month) && (31>=day) && (1=8) && ((month % 2)==1) && (day>=31)){//alert ("This month is a small month!");return 0;}if ((month==2) && (day==30)){//alert("The Febryary never has this day!");return 0;}return 1;}//函数名:fucPWDchk//功能介绍:检查是否含有非数字或字母//参数说明:要检查的字符串//返回值:0:含有 1:全部为数字或字母 function fucPWDchk(str){var strSource ="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";var ch;var i;var temp;for (i=0;i
业务咨询

Copyright 2003 - 2023 huinet.cn All Rights Reserved.
慧网公司 版权所有