欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

asp form 表单验证函数

程序员文章站 2023-08-24 12:53:04
'************************************* '检测是否只包含英文和数字 '********************************...
'*************************************
'检测是否只包含英文和数字
'*************************************

function isvalidvalue(arrayn, str)
isvalidvalue = false
dim gname
for each gname in arrayn
if str = gname then
isvalidvalue = true
exit for
end if
next
end function

'*************************************
'检测是否有效的数字
'*************************************

function isinteger(para)
isinteger = false
if not (isnull(para) or trim(para) = "" or not isnumeric(para)) then
isinteger = true
end if
end function

'*************************************
'用户名检测
'*************************************

function isvalidusername(byval username)
dim i, c
dim vusername
isvalidusername = true
for i = 1 to len(username)
c = lcase(mid(username, i, 1))
if instr("$!<>?#^%@~`&*();:+='""     ", c) > 0 then
isvalidusername = false
exit function
end if
next
for each vusername in register_username
if username = vusername then
isvalidusername = false
exit for
end if
next
end function

'*************************************
'检测是否有效的e-mail地址
'*************************************

function isvalidemail(email)
dim names, name, i, c
isvalidemail = true
names = split(email, "@")
if ubound(names) <> 1 then
isvalidemail = false
exit function
end if
for each name in names
if len(name) <= 0 then
isvalidemail = false
exit function
end if
for i = 1 to len(name)
c = lcase(mid(name, i, 1))
if instr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 and not isnumeric(c) then
isvalidemail = false
exit function
end if
next
if left(name, 1) = "." or right(name, 1) = "." then
isvalidemail = false
exit function
end if
next
if instr(names(1), ".") <= 0 then
isvalidemail = false
exit function
end if
i = len(names(1)) - instrrev(names(1), ".")
if i <> 2 and i <> 3 then
isvalidemail = false
exit function
end if
if instr(email, "..") > 0 then
isvalidemail = false
end if
end function