I want to create a very minimal login block and thus wouldn't like to have the "log in" button at all. I would like to have only the username and password fields, and log on by hitting "enter".

I have added display:none CSS property to the button, but this will stop form from being submitted. What else could be done ?

  • just css display:none; but then i can't log in using this form because the button is missing :)
    – Nim
    Commented Jan 7, 2013 at 14:27
  • 5
    Hiding the button with CSS won't stop the form from submitting when enter is pressed, if you're looking for a quick-fix that's it. Bear in mind you're not doing much for UX here, people expect a call-to-action to continue.
    – Clive
    Commented Jan 7, 2013 at 14:33
  • But so it does. I can't submit if the button is display:none; on css (I got ajax login module active)
    – Nim
    Commented Jan 7, 2013 at 14:39
  • 1
    visibility:hidden Will work ! Just tried it.
    – GoodSp33d
    Commented Jan 7, 2013 at 14:44
  • @2-Stroker With the ajax login module active it probably won't (the JS will intercept the default form submit). Try doing it with jQuery: $('#login-textfield').keydown(function(e) { if (e.which == 13) { $('#login-button').click(); }); or something
    – Clive
    Commented Jan 7, 2013 at 14:46

1 Answer 1


The jquery approach to achieve this one which worked for me (drupal 7) is the following code

$("#edit-pass").keypress(function(event) {
  if ( event.which == 13 ) {


$("#edit-name").keypress(function(event) {
  if ( event.which == 13 ) {

#edit-name and #edit-pass are my two login fields.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.