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

一个判断email合法性的函数[非正则]

程序员文章站 2022-06-19 19:36:50
<% function isvalidemail(email) dim names, name, i, c isvalidemail = true names = s...

<%
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
%>