Lightning Component email validation

Custom Email Field Validation in Salesforce Lightning Component

Lightning Component

Hi Ohana,
Today’s, In This Sample Example We will know that how to Add Custom Email Field Validation in Salesforce Lightning Component with Client Side(java Script) controller.

Basically email address is a string (a subset of different ASCII characters) which is divided into 2 parts by @ symbol. a “special_information” and a domain, such as: special_information@domain.
The length of the special_information part may be up to 64 characters long and the domain name may be up to 253 characters.

I am using javaScript Email Address Regular Expression, That 99.99% Works -:


Valid Email Addresses Samples
  • (one-letter local-part)
  • #!$%&’*+-/=?^_`{}|
Invalid Email Addresses Samples
  • (no @ character)
  • (only one @ is allowed outside quotation marks)
  • a”b(c)d,e:f;g<h>i[j\k] (none of the special characters in this local-part are allowed outside quotation marks)
  • this is”not\ (spaces, quotes, and backslashes may only exist when within quoted strings and preceded by a backslash)
  • this\ still\”not\\ (even if escaped (preceded by a backslash), spaces, quotes, and backslashes must still be contained by quotes)
  • (double dot before @)
  • (double dot after @)

Email Field Validation image gif Lightning Component

Lightning Component Code [EmailValidation.cmp] 

 JavaScript Controller Code [EmailValidationController.js]

  • See code Comments 🙂

After the winter 17 release you can  use the Lightning Design System style in Lightning Apps by extends=”fore:slds”.  The Salesforce Lightning Design System provides a look & feel that’s consistent with Lightning Experience. Use Lightning Design System styles to give your custom applications a UI that is consistent with Salesforce.

Like our facebook page for new post updates. & Don’t forget to bookmark this site for your future reference.

if you have any suggestions or issue with it, you can post in comment box 🙂

(Visited 12,014 times, 1 visits today)


Leave a Reply