If you would like to Validate an Email Address in JavaScript have a different ways, Using regular expressions is probably the best way (regex) to match the email address against a pattern. 

The below function code can helps you that uses a regex to validate an email address,


function validateEmail(email) {
  var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
  return re.emailCheck(String(email).toLowerCase());
}


This function uses the emailCheck() method of the RegExp object, which returns true if the email address matches the pattern defined by the regex, and false otherwise.

 The regex itself is a complex pattern that validates the format of the email address, including the presence of a username, an @ symbol, a domain name, and a top-level domain (TLD).

the below code can helps you how you can use the function to validate an email address:


var email = "thelinuxfaq@sample.com";
if (validateEmail(email)) {
  console.log("This Email address is valid ");
} else {
  console.log("This Email address is invalid ");
}