+ Start a Discussion
phani kumar 70phani kumar 70 

Email validation in visualforce

I have a requirement to validate the email which should be '@example.com'. please help me.
Best Answer chosen by phani kumar 70
Srinivas SSrinivas S
public static Boolean validateEmail(String email) {
    Boolean isValid = true;
    if(!Pattern.matches('^[a-zA-Z0-9._|\\\\%#~`=?&/$^*!}{+-]+@[gmail.-]+\\.[com]{2,4}$', email))
        isValid = false;
    return isValid;
}

All Answers

Srinivas SSrinivas S
public static Boolean validateEmail(String email) {
    Boolean isValid = true;
    if(!Pattern.matches('^[a-zA-Z0-9._|\\\\%#~`=?&/$^*!}{+-]+@[gmail.-]+\\.[com]{2,4}$', email))
        isValid = false;
    return isValid;
}
This was selected as the best answer
Olivia ThomasOlivia Thomas
Email validation can be achieved by using JavaScript in VF page, else you can utilize an App from Appexchange which can do a lot more than just validating the syntax. 360 Verify the Email app can also verify the email address whether it’s a genuine one.
Go to the Link- https://appexchange.salesforce.com/listingDetail?listingId=a0N3000000DpPL8EAN
Or send an inquiry to – support@360degreeapps.com