Skip to content

Instantly share code, notes, and snippets.

@ifnull
Created January 20, 2013 06:02
Show Gist options
  • Save ifnull/4576905 to your computer and use it in GitHub Desktop.
Save ifnull/4576905 to your computer and use it in GitHub Desktop.
Make the enter key work with Drupal login
Drupal.behaviors.loginAJAXSubmit = {
attach: function (context, settings) {
var ajax = Drupal.ajax[$('#tab-login .form-submit').attr('id')];
if(typeof ajax != 'undefined'){
$('input',ajax.element_settings.element.parentElement.parentElement).bind("keypress", function (e) {
var code = (e.keyCode ? e.keyCode : e.which);
if(code == 13) { //Enter keycode
$(ajax.element_settings.element).trigger(ajax.element_settings.event);
}
});
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment