I'm making a password thing for my website. How can I check if the password is correct by pressing the enter key instead of pressing the submit button? Help would be appreciated.
<html>
<script>
function checkPassword() {
var password = document.getElementById("passwordBox");
var passwordText = password.value;
if(passwordText == "password") {
alert("you got it right");
return true;
}
alert("you got it wrong");
return false;
}
</script>
</head>
<body>
<p style="font-size: 30pt;">something</p>
<p>Please enter the password to uh... something </p>
<p>Password: <input id="passwordBox" type="password"/></p>
<button onclick="return checkPassword();">
Submit
</button>
</html>