Looking to improve the HTML code
(reviewing changes)
Still learning how to create a website, so there might be errors in the code. I'm using neocities.org as the platform. I tried customizing the HTML source but struggling with removing the white space around the boxes. Will work on fixing it later.
I'd like to learn how to create a form that redirects to a new page upon entering the correct answer.
Website URL:
UPDATES:
<!DOCTYPE html>
<html>
<head>
<style>
div {
height: 200px;
width: 400px;
position: fixed;
top: 50%;
left: 55%;
margin-top: -100px;
margin-left: -200px;
}
body {
background-image: url("https://proxy.duckduckgo.com/iu/?u=http%3A%2F%2Fgetwallpapers.com%2Fwallpaper%2Ffull%2F4%2Fc%2Fc%2F36974.jpg&f=1&nofb=1");
background-color: #cccccc;
}
function {
color: red;
}
</style>
<body>
<script>
var incorrectCount = 0;
var correctPassword = "randompassword"
function checkPassword(){
var enteredPassword = document.getElementById("txtpassword").value;
if(enteredPassword != correctPassword)
incorrectCount++
else{
incorrectCount = 0
document.getElementById("userMessage").innerHTML = "Correct Password !!"
window.location.href = "http://www.w3schools.com";
}
if(incorrectCount == 3){
document.getElementById("userMessage").innerHTML = "Incorrect password entered 3 or more times"
document.getElementById("userMessage").style.visibility = "visible";
}
}
</script>
<div>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Login</title>
<form>
<p><input style="background-color:red;color:black;border:1px solid #ff0000" type="text" id="randompassword" name="login" value="" placeholder="Username"></p>
<p><input style="background-color:red;color:black;border:1px solid #ff0000" type="password" id="something" name="password" value="" placeholder="********"></p>
<a class="submit"><input type="submit" id="loginbutton" onclick="checkPassword()" name="commit" value="Login"><br>
<label id="userMessage" style="visibility:hidden;"></label>
</a>
</form>
</div>
</body>
</html>