ASP几个常用的判断函数
2005-10-25 14:55
405 查看
在取得用户输入信息的时候,我们常常要判断用户输入的有效性.
下面几个是常用的 :
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
是奇数返回真,是偶数返回假。
下面几个是常用的 :
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
是奇数返回真,是偶数返回假。
相关文章推荐
- ASP常用的几个功能模块封装成函数调用(登录验证,状态切换。。) http://www.tsingfeng.com/archives/?article-89.html
- 黑马程序员之ASP.NET学习笔记: 几个常用方法有效优化ASP.NET的性能
- ASP.NET常用的几个方法
- ASP.Net核心对象之context.Server对象几个常用方法
- ASP常用的几个功能模块
- 发现几个常用的asp.net MVC Helper 源码
- Asp.net中数字的字符串转换数值的几个常用函数(留着备用)
- ASP.NET中常用的几个李天平开源公共类LTP.Common,Maticsoft.DBUtility,LtpPageControl (转)
- ASP.NET页面几个常用表单验证
- 几个常用方法有效优化ASP.NET的性能
- ASP.NET中常用的几个李天平开源公共类LTP.Common,Maticsoft.DBUtility,LtpPageControl
- ASP中常用的转义字符及编码、测试时应注意的几个要点
- ASP.NET中常用的几个李天平开源公共类LTP.Common,Maticsoft.DBUtility,LtpPageControl
- asp中几个常用的编码转换函数
- 用ASP.NET(WebForm模式)开发WebAPI的几个常用方法
- 提高ASP.NET性能与可伸缩性的几个个常用方法剖析
- ASP常用的几个功能模块
- 提高ASP.NET性能与可伸缩性的几个个常用方法剖析
- 分享 [ASP.NET]几个常用的MVC设置
- 提高ASP.NET性能与可伸缩性的几个个常用方法剖析