HTML CSS Javascript jQuery AJAX PHP Java MORE

How to validate email in JavaScript

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JavaScript form validation - checking email</title>
</head>
<body >
<div class="mail">
<h2>Input an email and Submit</h2>
<form name="form1" action="#">
<input type='text' name='text1'/>
<input type="button" name="submit" value="Submit" onclick="ValidateEmail(document.form1.text1)"/>
</form>
</div>
<script>
function ValidateEmail(inputText)
{
var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
if(inputText.value.match(mailformat))
{
alert("Valid email id!");
document.form1.text1.focus();
return true;
}
else
{
alert("You have entered an invalid email address!");
document.form1.text1.focus();
return false;
}
}
</script>
</body>
</html>

Run it yourself