0) And (InStr(1, Email, ".") > 0) Then atCount = ;更新日期:2024/10/8.幽灵资源网,磁力链接,云盘下载,BT种子,CPU天梯,显卡天梯,UU加速器,阅读3.0,英雄联盟,怪物猎人,王者荣耀,绿色地狱合成表,无损音乐网,无损音乐下载网站,无损音乐免费下载,320Kmp3下载,无损音乐免费下载网站,音画欣赏,无损音乐,抖音神曲,发烧大碟,车载歌曲,试音天碟,WMA,WAV+CUE,WAV整轨,FLAC分轨,DSD黑胶,HI-FI试音,SACD-ISO,4K高清,高清电影下载,Magnet,Torrent,BitTorrent,迅雷快传,SUB,SRT,ASS/SSA,SUP,RARBG,TLF字幕,BluRay,x265,x264,DTS-HD,WEBRip,10BIT,HDR,DDP5.1,WEB-DL,1080p高清电影下载,中国高清网,高清电影,720p,1080p,MKV,AVI,蓝光原盘,3D高清,电影下载,qq飞车紫钻,序列号,破解版,注册机,绿色版,教程网,互联网资源,福利资源,网络流行语,高清电影,韩剧美剧,动漫资讯,游戏教程,LOL资讯视频,CF活动大全,LOL最新活动,CF实用技巧,DNF活动资讯,王者荣耀,技术教程,SEO教程,网络教程,破解软件,游戏软件,网站源码,易语言源码,安卓软件,汉化版,度盘,百度云盘,蓝奏,微云盘,网盘,无广告纯净版,不限速下载,去广告,修改器,VIP解析,SN,PSCS6,万圣节的新娘,MusicTag,百度文库,原神">

如何判断电子邮件的地址格式是否正确?

网络编程 发布日期:2024/10/8 浏览次数:1

正在浏览:如何判断电子邮件的地址格式是否正确?

第一种办法:

<%

Function IsValidEmail(Email)

ValidFlag = False

If (Email <> "") And (InStr(1, Email, "@") > 0) And (InStr(1, Email, ".") > 0) Then

atCount = 0

SpecialFlag = False

For atLoop = 1 To Len(Email)

atChr = Mid(Email, atLoop, 1)

If atChr = "@" Then atCount = atCount + 1

If (atChr >= Chr(32)) And (atChr <= Chr(44)) Then SpecialFlag = True

If (atChr = Chr(47)) Or (atChr = Chr(96)) Or (atChr >= Chr(123)) Then SpecialFlag = True

If (atChr >= Chr(58)) And (atChr <= Chr(63)) Then SpecialFlag = True

If (atChr >= Chr(91)) And (atChr <= Chr(94)) Then SpecialFlag = True

Next

If (atCount = 1) And (SpecialFlag = False) Then

BadFlag = False

tAry1 = Split(Email, "@")

UserName = tAry1(0)

DomainName = tAry1(1)

If (UserName = "") Or (DomainName = "") Then BadFlag = True

If Mid(DomainName, 1, 1) = "." then BadFlag = True

If Mid(DomainName, Len(DomainName), 1) = "." then BadFlag = True

ValidFlag = True

' 格式正确返回Ture。

End If

End If

If BadFlag = True Then ValidFlag = False

' 格式不正确返回False。

IsValidEmail = ValidFlag

End Function

%>

 

    第二种办法:

<%
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 isEmail(pInString)

  lAt = False
  lDot = false

  for x = 2 to len(pInstring)-1
    if mid(pInString,x,1) = "@" then lAt = True
      if mid(pInString,x,1) = "." and lAt = True then lDot = True
  next

  if lAt = True and lDot = True then
    isEmail = True
  else
    isEmail = False
  end if
end function

 

[1]