在取得用户输入信息的时候,我们常常要判断用户输入的有效性.
下面几个是常用的 :
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
是奇数返回真,是偶数返回假。