if(document.userinfo.useremail.value.length!=0)
  {
    if (document.userinfo.useremail.value.charAt(0)=="." ||        
         document.userinfo.useremail.value.charAt(0)=="@"||       
         document.userinfo.useremail.value.indexOf('@', 0) == -1 || 
         document.userinfo.useremail.value.indexOf('.', 0) == -1 || 
         document.userinfo.useremail.value.lastIndexOf("@")==document.userinfo.useremail.value.length-1 || 
         document.userinfo.useremail.value.lastIndexOf(".")==document.userinfo.useremail.value.length-1)
     {
      alert("Email地址格式不正确!");
      document.userinfo.useremail.focus();
      return false;
      }
   }
 else
  {
   alert("Email不能为空!");
  }

解决方案 »

  1.   

    var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_@.";
    var checkStr = document.info.emailadd.value;
    var allValid = true;
    for (i = 0;  i < checkStr.length;  i++)
    {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
    if (ch == checkOK.charAt(j))
    break;
    if (j == checkOK.length)
    {
    allValid = false;
    break;
    }
    } if (document.info.emailadd.value.length < 6)
    {
    allValid = false;
    } if (!allValid)
    {
    alert("您输入的 \"电子邮件地址\" 无效!");
    document.info.emailadd.focus();
    return (false);
    } address=document.info.emailadd.value;
        if(address.length>0)
    {
            i=address.indexOf("@");
            if(i==-1)
    {
    window.alert("对不起!您输入的电子邮件地址是错误的!")
    document.info.emailadd.focus();
    return false
            }
           ii=address.indexOf(".")
            if(ii==-1)
    {
    window.alert("对不起!您输入的电子邮件地址是错误的!")
    document.info.emailadd.focus();
    return false
            }    }
    if (checktext(document.info.emailadd.value))
    {
    alert("请您输入有效的\"email\"!");
    document.info.emailadd.select();
    document.info.emailadd.focus();
    return (false);
    }
    function checktext(text)
    {
    allValid = true; for (i = 0;  i < text.length;  i++)
    {
    if (text.charAt(i) != " ")
    {
    allValid = false;
    break;
    }
    }return allValid;
    }
      

  2.   

    简单一点的
    if ( !str.match(/^[a-zA-Z0-9_-]+@[a-zA-Z0-9-]+\./(com|cn|net|name|org|info|biz|tv|cc)(\.[a-zA-Z]{0-3})?$/i )
      alert("不是有效的E-MAIL地址!");
      

  3.   

    不好意思,用下面的
    if ( !str.match(/^[a-zA-Z0-9_-]+@[a-zA-Z0-9-]+\.(com|cn|net|name|org|info|biz|tv|cc)(\.[a-zA-Z]{0-3})?$/i )
      alert("不是有效的E-MAIL地址!");
      

  4.   

    http://blog.csdn.net/kingerq/archive/2004/11/24/193763.aspx
      

  5.   

    <html>
    <head>
    <title>签写留言</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <script>
    <!--
    function Juge(theForm)
    {

    if (theForm.email.value == "")
    {
    alert("请您输入\"email\"!");
    theForm.email.focus();
    return (false);
    } var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_@.";
    var checkStr = theForm.email.value;
    var allValid = true;
    for (i = 0;  i < checkStr.length;  i++)
    {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
    if (ch == checkOK.charAt(j))
    break;
    if (j == checkOK.length)
    {
    allValid = false;
    break;
    }
    } if (theForm.email.value.length < 6)
    {
    allValid = false;
    } if (!allValid)
    {
    alert("您输入的 \"电子邮件地址\" 无效!");
    theForm.email.focus();
    return (false);
    } address=theForm.email.value;
        if(address.length>0)
    {
            i=address.indexOf("@");
            if(i==-1)
    {
    window.alert("对不起!您输入的电子邮件地址是错误的!")
    theForm.email.focus();
    return false;
            }
           ii=address.indexOf(".")
            if(ii==-1)
    {
    window.alert("对不起!您输入的电子邮件地址是错误的!")
    theForm.email.focus();
    return false;
            }    }
    if (checktext(theForm.email.value))
    {
    alert("请您输入有效的\"email\"!");
    theForm.email.select();
    theForm.email.focus();
            return (false);
    }
    }</script>
    <head>
    </head>
    <body>
    <form action="guestBook_save.asp" method="post" onSubmit="return Juge(PostTopic)" name="PostTopic" >
      电子邮件:
        <input type="text" name="email" maxlength="30" size="25"  style="border:1px double rgb(88,88,88);font:9pt">
        <input type="submit" name="Submit" value="提交">
    </form>
    </body>
    </html>这是调用的一种方法,具体的脚本你可以再修改一下
      

  6.   

    <Script> 
    function checkForm(){
    var email=document.emailform.email.value;
    var pattern=/^([a-zA-Z0-9])+@([a-zA-Z0-9])+\.([a-zA-Z0-9])+/;
    flag=pattern.test(email);
    if(flag)
    {   
    return ture;
    }
    else{
                      alert("不是合法的邮件格式!!");
                      document.emailform.email.focus();
             return false;
             }
    </Script>