Email Validation under Form validation in Javascript
<!DOCTYPE html>
<html lang="en" id="hello">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title> Email Validation under Form validation in Javascript</title>
<link rel="stylesheet" href="latesttest.css">
</head>
<body>
<form onsubmit=" return validation()">
EMAIL ID <input id="user" type="email" placeholder="EMAIL ID" required><br><br>
PASSWORD <input id="pass" type="password" placeholder="PASSWORD"><br><br>
<button type="submit">SUBMIT</button>
</form>
<script>
function validation()
{
var v = document.getElementById("user").value;
var a = v.indexOf("@");
var b = v.lastIndexOf(".");
var c = v.indexOf(".")-v.indexOf("@") ;
alert("VALUE OF A: " + a + "value of B : " + b + "value of c : " + c)-2;
if( a<1 || b<2 || c<=2 )
return false;
else
return true;
}
</script>
</div>
</body>
</html>
Comments
Post a Comment
I WOULD APPRECIATE IF YOU LEAVE A COMMENT OR YOUR FEEDBACK HERE !!!