Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

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
1  
What have you tried so far? –  Clive Jan 7 '13 at 14:26
    
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
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 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
1  
visibility:hidden Will work ! Just tried it. –  2-Stroker Jan 7 '13 at 14:44
show 2 more comments

1 Answer

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-submit').click();
   }

});

$("#edit-name").keypress(function(event) {
  if ( event.which == 13 ) {
    $('#edit-submit').click();
}});

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

share|improve this answer
add comment

Your Answer

 
discard

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.