Embed presentation
Download to read offline
![E-mail Validation
<!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;
}
}
</script>
</head>
<body>
<form name="myForm" action="demo_form.asp" onsubmit="return validateForm();" method="post">
Email: <input type="text" name="email">
<input type="submit" value="Submit">](https://image.slidesharecdn.com/e-121105031411-phpapp02/75/E-by-karan-chanana-1-2048.jpg)


This document contains JavaScript code to validate email addresses entered into a form. The code checks that the email contains an "@" symbol, that the "." symbol occurs after the "@" symbol, and that there is at least one character after the "." symbol. If any of these conditions are not met, an alert will display to notify the user that they did not enter a valid email address.
![E-mail Validation
<!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;
}
}
</script>
</head>
<body>
<form name="myForm" action="demo_form.asp" onsubmit="return validateForm();" method="post">
Email: <input type="text" name="email">
<input type="submit" value="Submit">](https://image.slidesharecdn.com/e-121105031411-phpapp02/75/E-by-karan-chanana-1-2048.jpg)
