topical media & game development

talk show tell print

professional-javascript-07-EmailExample.htm / htm



  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  
  <html>
      <head>
          <title>E-mail Example</title>
          <script type="text/javascript">
      
  
                  function isValidEmail(sText) {
                      var reEmail = /^(?:\w+\.?)*\w+@(?:\w+\.)+\w+/;
                      return reEmail.test(sText);
                  }
  
                  
                  function validate() {
                      var oInput1 = document.getElementById("txt1");
                      if (isValidEmail(oInput1.value)) {
                          alert("Valid");
                      } else {
                          alert("Invalid!");
                      }
  
                  }
          </script>
      </head>
      <body>
          <p>E-mail Address: <input type="text" id="txt1" /><br />
          <input type="button" value="Validate" onclick="validate()" /></p>
         
      </body>
  </html>
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.