ASP几个常用的判断函数

在取得用户输入信息的时候,我们常常要判断用户输入的有效性.
下面几个是常用的 :

1,检查输入字段是否为日期类型

function xdate(inputdate)
  if not is date(inputdate) then 
     xdate=0
  elseif 
     cdate(inputdate)>date then
     xdate=0
  else
     xdate=1
  end if 
end function

2.邮政编码

funciton xzip(inputzip)
  if isnumeric(inputzip) then
     if len(inputzip)=6 then
        xzip=1
     else 
        xzip=0
     end if 
  else
    xzip=0
  end if 
end function

3.电子邮件
function xemail(inputemail)
    theat=instr(2,inputemail,"@")
    if theat=0 then
       xemail=0
    else
       thedot=instr(cint(theat)+2,inputemail,".")
       if thedot=0 then 
           xemail=0
       elseif cint(thedot)+1>len(inputemail)
       then
          xmail=0
        else
         xmail=1
     end if 
   end if
end function


1,先写脚本,用if else 判断代码的有效性,
然后将错误消息给一个变量。
2,用该变量的值来决定网页的流向和输出。
还有一种方法是将网页的提交按扭设为button。
onclick 属性 触发子程序。(写成子程序)

     判断一个数是奇数还是偶数?
function Is_odd(num) as boolean 
n=num mod 2 
if n=1 then 
Is_odd=true 
else 
Is_odd=false 
end if 
end function 
是奇数返回真,是偶数返回假。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值