title: Compare two emails in two text fields using Javascript
body: <p>I have a form which lets the user to enter the email address twice. i need to validate that the email is like the regex and that the two emails match.</p>
  
  <p>Something is wrong with my code. Please note that i am restricted to use javascript only. Thanks,
  this is my javascript</p>
  
  <pre><code>function checkEmail(theForm) {
  
      var re = /^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@"+"[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$/i;
  
      if (theForm.EMAIL_1.value != re) {
          alert('invalid email address');
          return false;
      } else if (theForm.EMAIL_1.value != theForm.EMAIL_2.value) {
          alert('Those emails don\'t match!');
          return false;
      } else {
          return true;
      }
  }
  </code></pre>