---
title: "用javascript的正则表达式来验证Email地址是否格式正确"
author: "jwen"
date: "2007-03-14T12:47:51Z"
tags: []
slug: "javascript-email"
draft: false
lastmod: "2007-03-14T12:47:51Z"
id: 59760
url: "https://jwen.iteye.com/blog/59760"
---

```

function CheckExists()
   {
       var e = document.getElementById("mailaddress").value;
        if(e != "") {
            if(!/(\S)+[@]{1}(\S)+[.]{1}(\w)+/.test(e)) 
           {
               alert("请输入格式正确的 e-mail 地址！");
               var email = document.getElementById ( "mailaddress" );
               email.value = "";
               email.focus ();
           } 
            else 
            {
             QuickRegisterBox.IsEMailExists(e, CheckExists_Callback);
            }
       }
   } 

```