4

On https://security.stackexchange.com/users/login page for a site where I don't yet have an account, if I select the "Log in using Stack Exchange" box, when I hit enter from the password form, nothing happens.

Minor, but...

3

2 Answers 2

2

This will be fixed in the next build. Hitting enter in the log in or signup forms will submit as expected.

0

I've added a client-side fix for this issue into the Stack Overflow Unofficial Patch v1.10.

Basically, the cause of the problem is that the "submit" button on the form is not really a normal <input type=submit> element, and so the auto-submit-on-enter feature in most browsers is not applied to the form. The fix is simply to emulate it with a custom keypress event handler in JavaScript, just like is done e.g. for the comment input boxes (which are really <textarea>s, and thus also don't auto-submit on enter):

var inputs = 'input[name=email], input[name=password]';

$('.login-page #se-login-form').on( 'keypress', inputs, function (e) {
    if ( e.which != 13 || e.shiftKey || e.defaultPrevented ) return;

    e.preventDefault();
    e.stopImmediatePropagation();

    var empty = $(e.delegateTarget).find(inputs).filter('[value=""]');
    if ( empty.length > 0 ) empty.first().focus();
    else $(e.delegateTarget).find('#submit-button').click();
} );

What this code does is trigger on Enter key presses in either of the e-mail / password input boxes, assuming that (just to be safe) no other event handler has stopped them or prevented their default behavior yet. It then checks if both of the fields are filled, and, if so, simulates a click on the submit button; otherwise, it transfers input focus to the first empty field.

1
  • ...and now that it's fixed, this code has been removed from SOUP v1.12. Apr 15, 2014 at 0:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .