几个常用的小函数

2016-01-29 19:53 22 1 收藏

几个常用的小函数,几个常用的小函数

【 tulaoshi.com - ASP 】

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

//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;j<i;j++)
{
if (num.charAt(j)=='.')
{
status++;
}
if (status1)
{
//alert("You have enter a invalid number.");
return 0;
}
if (num.charAt(j)<'0' || num.charAt(j)'9' )
{
if (((opt1==0) || (num.charAt(j)!='.')) && (j!=0))
{
//alert("You have enter a invalid number.");
return 0;
}
}
}
return 1;
}

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/asp/)

//函数名:chkdate
//功能介绍:检查是否为日期
//参数说明:要检查的字符串
//返回值:0:不是日期 1:是日期
function chkdate(datestr)
{
var lthdatestr
if (datestr != "")
lthdatestr= datestr.length ;
else
lthdatestr=0;

var tmpy="";
var tmpm="";
var tmpd="";
//var datestr;
var status;
status=0;
if ( lthdatestr== 0)
return 0

for (i=0;i<lthdatestr;i++)
{ if (datestr.charAt(i)== '-')
{
status++;
}
if (status2)
{
//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.length2) || (tmpd.length2))
{
//alert("Invalid format of date!");
return 0;
}
if (!((1<=month) && (12=month) && (31=day) && (1<=day)) )
{
//alert ("Invalid month or day!");
return 0;
}
if (!((year % 4)==0) && (month==2) && (day==29))
{
//alert ("This is not a leap year!");
return 0;
}
if ((month<=7) && ((month % 2)==0) && (day=31))
{
//alert ("This month is a small month!");
return 0;

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/asp/)

}
if ((month=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;
}
//函数名:chksafe
//功能介绍:检查是否含有"'",'',"/"
//参数说明:要检查的字符串
//返回值:0:是 1:不是
function chksafe(a)
{
return 1;
/* fibdn = new Array ("'" ,"", "、", ",",

来源:https://www.tulaoshi.com/n/20160129/1510306.html

延伸阅读
翻译的不好,请见谅。 翻译:鲁小班 文件: ActnList CreateAction 函数 创建一个指定类型的Action,显示在action list editor中。 EnumRegisteredAction 过程 枚举已经注册的Action RegisterAction 过程 注册Action UnRegisterAction 过程 反注册Action 文件: Classes Bounds 函数 输入上...
标签: Web开发
代码如下: %       page=trim(request("page"))       maxperpage=40       first=true       last=true       dim rs       set r...
标签: ASP
  <% sub Jmail(email) Dim JMail,SendMail Set JMail=Server.CreateObject("JMail.SMTPMail") JMail.Logging=True JMail.Charset="gb2312" JMail.ContentType = "text/html" JMail.ServerAddress=SMTPServer JMail.Sender=SystemEmail JMail.Subject=topic JMail.Body=mailbody JMail.AddRecipient email JMail.Priority...
标签: Web开发
代码如下:     rs.open sql,conn,1,1     if rs.eof and rs.bof then      response.write "p align='center'还没找到文章/p"   else    totalPut=rs.recordcount    maxperpage=18 &nb...
标签: Web开发
Abs(number) 取得数值的绝对值。    Asc(String) 取得字符串表达式的第一个字符ASCII 码。    Atn(number) 取得一个角度的反正切值。    CallByName (object, procname, usecalltype,[args()]) 执行一个对象的方法、设定或传回对象的属性。 &nbs...

经验教程

917

收藏

100
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部