if InStr(text1.value,"@") = 0 then
   MsgBox"E-mail中需要包含‘@’字符!",64,"Oh no!"
end if其中text1为要填写的文本框!

解决方案 »

  1.   

    楼主是不是打算自己写验证Email格式的东西啊,那还要判断其他条件哪,建议你用现成的正则表达式来判断email。
      

  2.   

    BBS 里抄的。'判断EMAIL 格式
    function IsValidEmail(email)
    dim names, name, i, c
    'Check for valid syntax in an email address.
    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
      

  3.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    </HEAD>
    <!--用一个判断语句,如果“e-mail”为空就不执行那段函数就可以了阿!
    /……/表示一个锚,^表示开始,$是结尾\w是所有字符()是一个实体 \. 转移“.” | 可以理解为“or”其他的自己看着办了!
    -->
    <BODY>
    <script>
    function checkEmail(){
    var emailPattern = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
    if (emailPattern.test(emails.value)==false)
    alert("非法的Email地址!")
    else
    alert("正确的Email地址!")
    }
    </script>
    <input id=emails><input type=button value=CheckEmail onclick=checkEmail()>
    </BODY>
    </HTML>