Hey, I'm trying to make a web page with just a basic javascript login form, but something isn't working, and I don't know what. Please, don't post saying that the form is too simple, or that I should just do it with PHP or some other server-side language. It's just a test. All I want is to know what I am doing wrong.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Test JS Login</title>
<script type="text/javascript">
function Login(){
password = document.password
if (password.value == "yb6"){
link = document.getElementById("link")
link.href = "mypage.html"
}
else{
document.write("Wrong.")
}
}
</script>
</head>
<body>
<p align="center">
Please enter the password.
<br/>
<input name="password" type="password">
<br/>
<input type="button" value="Log in" onClick="Login()">
</p>
<a href="http://www.google.com" id="link">Enter the password to view my page.</a>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Test JS Login</title>
<script type="text/javascript">
function Login(){
password = document.password
if (password.value == "yb6"){
link = document.getElementById("link")
link.href = "mypage.html"
}
else{
document.write("Wrong.")
}
}
</script>
</head>
<body>
<p align="center">
Please enter the password.
<br/>
<input name="password" type="password">
<br/>
<input type="button" value="Log in" onClick="Login()">
</p>
<a href="http://www.google.com" id="link">Enter the password to view my page.</a>
</body>
</html>