We use Validation for Email in Javascript
like in above example
<!DOCTYPE html>
<html>
<head>
<script>
function validateForm() {
var x = document.forms["myForm"]["email"].value;
var atpos = x.indexOf("@");
var dotpos = x.lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length) {
alert("Not a valid e-mail address");
return false;
}
else
{
alert("Valid e-mail address");}
}
}
</script>
</head>
<body>
<form name="myForm" onsubmit="return validateForm();" >
Enter Email: <input type="text" name="email">
<input type="submit" value="Submit">
</form>
</body>
</html>
0 comments :
Post a Comment