The input string must have two minimum chars . One is @ and other one is presence of . ( dot ).
To ensure this, we will use indexOf function. If both are present then the function will return true so the form will be submitted otherwise it will return false.
Demo of email validation
Source code is here
<html>
<head>
<title></title>
</head>
<body >
<script type="text/javascript" >
function check_form(){
var em=document.getElementById('em').value;
if(em.indexOf("@") < 1 || em.indexOf(".") < 1 )
{
alert('Please check your email address');
return false;
}
alert('Email validation passed, you will be taken to tutorial page');
return true;
}
</script>
<form method=post action='email-validation.php' onsubmit='return check_form()'; name='myForm'>
<input type=text name=em id='em'><input type=submit value=Submit>
</form>
</body>
</html>