欢迎光临
我们一直在努力

几个常用的小函数1

建站超值云服务器,限时71元/月

//函数名: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;

}

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 几个常用的小函数1
分享到: 更多 (0)