Enter/return key submits form in the new user/password dialog
authorArt Cancro <ajc@citadel.org>
Tue, 18 Jan 2011 22:18:14 +0000 (17:18 -0500)
committerWilfried Goesgens <dothebart@citadel.org>
Sun, 4 Sep 2011 14:02:53 +0000 (14:02 +0000)
webcit/static/authmethods.js
webcit/static/t/get_logged_in.html

index 67018a7c2aaef8f59d639bc629f1289b371e5db2..4bb117c61754347bfae5336af1268757eb1e7ea0 100644 (file)
@@ -66,6 +66,23 @@ function ajax_try_username_and_password() {
        });
 }
 
+/*
+ * The user pressed a key while in the username or password box.
+ * Is it the enter/return key?  Submit the form.
+ */
+function username_and_password_onkeypress(e) {
+       if (window.event) {             /* IE */
+               keynum = e.keyCode
+       }
+       else if (e.which) {             /* real browsers */
+               keynum = e.which
+       }
+       if (keynum == 13) {             /* enter/return key */
+               ajax_try_username_and_password();
+       }
+}
+
+
 /*
  * tab handler for the login box
  */
index 3648eee1790d8b9854939ce4aca5a4b268030fe2..568f4c186ed8dec8ce7d2401e21e67d2bd1a8817 100644 (file)
 <h2><?_("Log in using a user name and password")></h2>
 <form id="ajax_username_password_form" method="POST" action="ajax_login_username_password">
 <?_("User name:")>
-<input type="text" name="name" id="uname">
+<input type="text" name="name" id="uname" onKeyPress="username_and_password_onkeypress(event);">
 <br><br>
 <?_("Password:")>
-<input type="password" name="pass" id="pname">
+<input type="password" name="pass" id="pname" onKeyPress="username_and_password_onkeypress(event);">
 <br><br>
 </form>
 <div class="buttons"><a href="javascript:ajax_try_username_and_password();"><?_("Log in")></a></div>