几个常用的小函数 |
作者:fightboat 发布时间:2005-03-12 来源:chinaasp.com
|
//函数名:chkemail //功能介绍:检查是否为Email Address //参数说明:要检查的字符串 //返回值:0:不是 1:是 function chkemail(a) { var i=a.length; var temp = a.indexOf('@'); var tempd = a.indexOf('.'); if (temp > 1) { if ((i-temp) > 3){ if ((i-tempd)>0){ return 1; } } } return 0; } //函数名:fucCheckNUM //功能介绍:检查是否为数字 //参数说明:要检查的数字 //返回值:1为是数字,0为不是数字 function fucCheckNUM(NUM) { var i,j,strTemp; strTemp="0123456789"; if ( NUM.length== 0) return 0 for (i=0;i<NUM.length;i++) { j=strTemp.indexOf(NUM.charAt(i)); if (j==-1) { //说明有字符不是数字 return 0; } } //说明是数字 return 1; } //函数名:fucCheckTEL //功能介绍:检查是否为电话号码 //参数说明:要检查的字符串 //返回值:1为是合法,0为不合法 function fucCheckTEL(TEL) { var i,j,strTemp; strTemp="0123456789-()# "; for (i=0;i<TEL.length;i++) { j=strTemp.indexOf(TEL.charAt(i)); if (j==-1) { //说明有字符不合法 return 0; } } //说明合法 return 1; } |
|
|
|
|