function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RaaaaaaJRaaaaaaJ 

How to validate domains of emails in apex

Hi folks,

 I have validate emails domians like @domains.com,@gmail.com ..like 49 domains.
i have 2 input texboxes in vf page and one submit button i have to give email address on each of the textbox
while hitting submit if the domain presents i need to allow to case otherwise i need to show error

Thanks
 
 
 

 
Gaurav NirwalGaurav Nirwal
if(!strAddress.endsWith('@volt.gov'))
{
  ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.Error, 'Invalid email domain used.');
  return null;
}
else
{
  // keep calm and carry on
}