email validation js

JavaScript
function isValidEmail(email) {
  const 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.test(String(email).toLowerCase());
}/* Answer to: "email regex javascript" */

ValidateEmail("[email protected]"); // Must be a string

function ValidateEmail(email) {
	var emailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(String(email).toLowerCase());
	if (email.match(emailformat)) {
    	alert("Nice Email!")
      	return true;
    };
    alert("That's not an email?!")
    return (false);
};/// if you want  create your regular expression then you can  follow this site 
/////https://regex101.com///////
<!DOCTYPE html>
<html>
<head>
	<title></title>
</head>
<body>
<form method="post" action="">
	Email:<input type="text"  id="email" onkeyup="validation()">
	</form>
</body>
<script type="text/javascript">
	function validation(){
	var email=document.getElementById("email").value;///get id with value 
	var emailpattern=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;////Regular expression
	if(emailpattern.test(email))
	{
		document.getElementById("email").style.backgroundColor='yellow';
    }
    else
    {
    	document.getElementById("email").style.backgroundColor='red'; }
	}

</script>
</html>
Source

Also in JavaScript: