Hey there! I've set up a text field where users need to input a password in order to download a PDF file. If the password is correct, they are directed to the URL of the PDF file. However, if the password is wrong, they are redirected to a page called "incorrect" (incorrect.html).
Everything seems to be working smoothly, except for one issue. When users press the Enter key, the page doesn't redirect; it only works when they click on the Submit button.
Is there a way to resolve this problem?
Thank you in advance!
Text Field and Submit Button Code
<form name="login">
<input class="gen-label" type="text" name="pass" size="17" onKeyDown="if(event.keyCode==13) event.keyCode=9;">
<input class="button submit" type="button" value="Submit" onClick="TheLogin(this.form)">
</form>
Javascript Code
<script>
function TheLogin() {
var password = 'Pass1';
if (this.document.login.pass.value == password) {
top.location.href="file_to_download.pdf";
}
else {
location.href="incorrect.html";
}
}
</script>