Use regex to validate email address - Javascript RegExp

Javascript examples for RegExp:Match Email

Description

Use regex to validate email address

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=( function() {//from  www  .j  ava 2  s  .  c o m
var myString="aaa@aaa.com";
var mailValidator = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
if (!mailValidator.test(myString))
{
    console.log("incorrect");
}
    });

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials