The function below checks if the content has the general syntax of an email.
This means that the input data must contain an @ sign and at least one dot (.). Also, the @ must not be the first character of the email address, and the last dot must be present after the @ sign, and minimum 2 characters before the end:
<html> <head> <title>JavaScript Validations</title> <script> function validateForm() { var x=document.forms["Form1"]["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="Form1" action="second.php" onsubmit="return validateForm()" method="post"> name: <input type="text" name="email"> <input type="submit" value="Submit"> </form> </body> </html>