Drupal Answers is a question and answer site for Drupal developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 ?

share|improve this question
just css display:none; but then i can't log in using this form because the button is missing :) – Nim Jan 7 '13 at 14:27
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 Jan 7 '13 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 Jan 7 '13 at 14:39
visibility:hidden Will work ! Just tried it. – GoodSp33d Jan 7 '13 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 Jan 7 '13 at 14:46
up vote 0 down vote accepted

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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