-2
 function verifyEmail(component){
        var status = false;
        var emailAddress = component.value;
        if(emailAddress == ""){
            return true;
        }
        var emailRegEx = /^([A-Z0-9._%+-])+@([A-Z0-9.-])+\.([A-Z])+$/i;
             if (!(emailAddress.search(emailRegEx) == -1)) {
                 status = true;
             }
             return status;
    }

This regex accepting duplicate words after @ . Eg: [email protected] Here com word is coming 2 times. we should not allow duplicate words after '@'

Ravi
  • 159
  • 3
  • 17

2 Answers2

0
 var emailRegEx = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/
Rhushikesh
  • 3,630
  • 8
  • 45
  • 82
0

you can use this /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,4}$/

Shobhit Walia
  • 496
  • 4
  • 19