如何正确的判断电子邮件的合法性?

itperson 2003-04-09 09:05:24
如何判断电子邮件中是否有“@”和“.”?如何判断“@”和“.”中间是否有内容?
...全文
280 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
bluesky1314520 2003-04-09
  • 打赏
  • 举报
回复
function IsValidEmail(email)
dim names,name,i,c
IsValidEmail=true
names=split(email,"@")
if UBound(names)<>1 then
IsValidEmail=false
exit function
end if

if IsNumeric(right(email,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
我用的,给你试试!
孟子E章 2003-04-09
  • 打赏
  • 举报
回复
搜索javascript版

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧