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

asp IsValidEmail 验证邮箱地址函数(email)

程序员文章站 2023-08-24 09:37:45
复制代码 代码如下:'******************************************** '函数名:isvalidemail '作 用:检查email...
复制代码 代码如下:

'********************************************
'函数名:isvalidemail
'作 用:检查email地址合法性
'参 数:email ----要检查的email地址
'返回值:true ----email地址合法
' false ----email地址不合法
'********************************************
public function isvalidemail(email)
dim names, name, i, c
isvalidemail = true
names = split(email, "@")
if ubound(names) <> 1 then isvalidemail = false: exit function
for each name in names
if len(name) <= 0 then isvalidemail = false:exit function
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
next
if left(name, 1) = "." or right(name, 1) = "." then isvalidemail = false:exit function
next
if instr(names(1), ".") <= 0 then isvalidemail = false:exit function
i = len(names(1)) - instrrev(names(1), ".")
if i <> 2 and i <> 3 then isvalidemail = false:exit function
if instr(email, "..") > 0 then isvalidemail = false
end function


其它语言可以参考: