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
'检测是否只包含英文和数字
'*************************************
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
上一篇: asp 下产生任意位数随机密码的代码
下一篇: ASP 快速执行动态网页