<!DOCTYPE html>
<html>
<head></head>
<body>
<form name="myForm" action="/action_page.php" method="post" onsubmit="return Function()">E-mail:
<input type="text" id="email" name="email">
<br>Password:
<input type="password" id="password" name="password">
<br>Repeat Password:
<input type="password" id="password2" name="password2">
<br>
<input type="submit" value="Register">
</form>
<script type="text/javascript">
function Function() {
var email = document.getElementById ("email").value;
var password = document.getElementById("password").value;
var password2 = document.getElementById("password2").value;
var emailpattern = /^[^ ]+@[^ ]+\.[a-z]{2,3}$/;
if (email.match.value(emailpattern)) {
alert ("Email is valid!");
return true;
}
else {
alert ("Not a valid email!");
return false;
}
if (email.length < 5) {
alert("Not a valid email!");
return false;
}
else {
alert("Email is valid!");
return true;
}
if (password.length < 4) {
alert("Password is too short");
return false;
}
else {
alert("Password is valid");
return true;
}
if (password2.length< 4) {
alert ("Password is too short");
return false;
}
else {
return true;
}
if (password != password2) {
alert ("Passwords does not much");
return false;
}
else {
return true;
}
}
</script>
</body>
</html>
If the post action page is not in the web root, remove the leading / from action="action_page.php"