-1

I'm using the pattern:

var pattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;

So when I submit/send an email to myself from my contact form to test out a bunch of different email combinations, everything has worked except for:

[email protected] && [email protected]

I'm not entirely sure why those two aren't being included, but I'd appreciate any assistance.

user5680735
  • 703
  • 2
  • 7
  • 21
Speakmore
  • 69
  • 2
  • 11

3 Answers3

0

I'm not sure whats going wrong with yours, but here's an email pattern I've used successfully.

pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$"
user4740600
  • 79
  • 1
  • 8
0

This help you :

 var patt = /^[A-Za-z0-9]+@[A-Za-z0-9]+\.[A-Za-z]+$/gmi

final code :

<html>
<head>
</head>
    <body>
        Enter Your Email : <input type="tel" id="email">
        <button onclick="isvalid()">Try</button>
        <p id="res"></p>
      <script>
          var res = document.getElementById("res");
          var patt = /^[A-Za-z0-9]+@[A-Za-z0-9]+\.[A-Za-z]+$/gmi
          function isvalid(){
              str = document.getElementById("email").value;
              if(patt.test(str))
                  res.innerHTML = "Email is Valid";
              else
                  res.innerHTML = "Email is InValid";
          }
      </script>
    </body>
</html>
Ehsan
  • 12,655
  • 3
  • 25
  • 44
0

I guess you miss some chars in your pattern, you may find here an answer

Validate email address in JavaScript?

there is a code which handles more chars that you forgot, and the comment above too.

Community
  • 1
  • 1
Ami Hollander
  • 2,435
  • 3
  • 29
  • 47