0

The below code is used to access a webpage I called myPage.html by entering a password of 1234. Once the password is entered the User either clicks the Login Button or presses the "Enter" key.

Clicking the login button works OK. My problem is that I have to press the Enter key twice for it to go to myPage.html

What do I need to change so I only have to press the Enter key once?


function TheLogin() {
var password = '1234';
if (this.document.login.pass.value == password) {
top.location.href="http://myPage.html";}
}

</script>
<p align="center">
<p align="center"><br>
<p align="center"><font size="5"><b><font color="#000000">Please enter the Password to Enter</font></b></font><br>
<p>&nbsp; </p>
<center>Enter your password:<br>
<form name="login" style="margin: 0px">


<INPUT TYPE="password" NAME="pass" size="17" onKeyDown="if(event.keyCode==13) event.keyCode=9;" style="width: 152px; margin: 5px;"><br>

<input type="button" value="Click to Login" style="width : 150px; margin: 3px" onClick="TheLogin(this.form)">
</form>
</center>

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by drjohn
0

Make '<input type="submit"' instead of '<input type="button"'...

Also why are you doing this login with JavaScript and not PHP?

Edited by shaya4207: Added last line

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.