I am relatively new to web development and I'm trying to do some form validation with javascript but my javascript block is not executing and I really don't know why. Any ideas?
<html>
<head>
<title>Login</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link type = "text/css" rel = "stylesheet" href = "formato.css" />
<script type = "text/javascript">
function validate(){
var x = document.forms[LoginInformation][username].value;
var y = document.forms[LoginInformation][password].value;
if(document.LoginInformation){
alert("Enter a username");
return false;
}
if(y===null || x ===""){
alert("Enter a password");
return false;
}
}
</script>
</head>
<body>
<center>
<div id = "login">
<form method = "post" name = "LoginInformation" onsubmit = "return (validate());" action="./TestLogin">
<fieldset>
<legend>Información de Login</legend>
<label>Usuario:<br />
<input type="text" name="username" size ="15"/></label><br />
<label>Contraseña:<br />
<input type="password" name="password" size ="15"/></label><br />
<label><br /><input type = "submit" name = "login" value = "Login"/></label><br />
</fieldset>
</form>
</div>
</center>
</body>