-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: leela.lokesh@in.csc.com.com Here com word is coming 2 times. we should not allow duplicate words after '@'

Ravi
  • 159
  • 3
  • 17
  • 2
    Please modify the title or it is a duplicate of [Validate email address in JavaScript?](http://stackoverflow.com/questions/46155/validate-email-address-in-javascript?rq=1). – Wiktor Stribiżew Mar 03 '16 at 09:36
  • `leela.lokesh@in.csc.com.com` is a valid email address. – Madara's Ghost Mar 03 '16 at 09:41
  • In the email address after @ duplicate words not allowed. I have given one emailRegEx it is not working. Can you provide any suggestions.If i give leela.suresh@in.csc.com.com it is taking. – Ravi Mar 03 '16 at 14:41
  • after@ there should not be any duplicate words. Eg: Gopi.infy@in.infy.infy.com.com if we see this email address after @ there are two infy words and two com words . those duplicates we should not allow – Ravi Mar 03 '16 at 14:43

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
  • it is not working it is allowing duplicates – Ravi Mar 03 '16 at 12:11
  • after@ there should not be any duplicate words. Eg: Gopi.infy@in.infy.infy.com.com if we see this email address after @ there are two infy words and two com words . those duplicates we should not allow – Ravi Mar 03 '16 at 14:42