Answers for "javascript email form validation"

5

js email regex

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());
}
Posted by: Guest on May-11-2020
0

email validation js

/// 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>
Posted by: Guest on January-24-2021
0

Email Validation in JavaScript

<!DOCTYPE html>
<html>
<head>
	<title>Email validation</title>
	<script type="text/javascript">
		function email_funnction() {
			var email = document.emailform.email.value;
			if(email.indexOf('@')<=0){
				document.getElementById('errormsg').innerHTML="Invalid your Email Address";
				return false;
			}     
			if ((email.charAt(email.length-4)!='.') && (email.charAt(email.length-3)!='.')) {
				document.getElementById('errormsg').innerHTML="Invalid your Email Address";
				return false;
			}
		}

	</script>
</head>
<body>
	<h1>Email Validation in javascript</h1>
	<span id="errormsg"></span>
<form name="emailform" onsubmit="return email_funnction()">
	
	<label>Email</label>
	<input type="text" name="email" value="">
	<input type="submit" name="" value="Submit">
</form>
</body>
</html>
Posted by: Guest on July-05-2020

Code answers related to "javascript email form validation"

Code answers related to "Javascript"

Browse Popular Code Answers by Language