The Login() function called by the onclick event is:
<SCRIPT LANGUAGE="JavaScript">
function Login(){
var done=0;
var username=document.login.username.value;
username=username.toLowerCase();
var password=document.login.password.value;
password=password.toLowerCase();
if (username=="username1" && password=="password1") { window.location="page1.html"; done=1; }
if (username=="username2" && password=="password2") { window.location="page2.html"; done=1; }
if (username=="username3" && password=="password3") { window.location="page3.html"; done=1; }
if (done==0) { alert("Login Invalid - try again."); }
}
// End -->
</SCRIPT>
I’ve tried a lot of different ways to get the Enter button to call the Login() function, but no luck. If I Tab-key the focus to the button after typing the password, it will do it. How do I get the focus over to that darn button, so Enter will trigger it?
You’re absolutely right, Charles. I tested it myself and it sure enough, it works. I thought from your previous post that the input type=submit was the necessary element to ensure Enter key functionality.
I did a google search and found this old post. Not to dig up old stuff but reading this thread helped me out so I thought I would help anyone else out that may find it.
The form does submit from any part with the enter keypress if there is a
One should think of non-visual viewers when making such forms… display:none will make three of the most popular screen readers not read it… meaning you’ll need something else to show those clients how to enter/submit the form.
input type=“image” works because it’s actually considered a submit button too.
As an extra note, it would be good if the Username and Password labels were in label tags with for=“blah” used to link (non-visually) the label and the input.