Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-19-2012, 07:52 PM   PM User | #1
mathceleb
Regular Coder

 
Join Date: Mar 2010
Posts: 235
Thanks: 39
Thanked 6 Times in 6 Posts
mathceleb is an unknown quantity at this point
jQuery click event not firing

When hitting the return key on the password field name="pass", the click event is not firing. form.submit is not an option since we need the click event to fire first.

We are using Drupal 7. Any thoughts?

PHP Code:
<div id="login-form-f" style="display:none;">
<
form action="/news" method="post" id="user-login" accept-charset="UTF-8"><div><div class="form-item form-type-textfield form-item-name">
  <
label for="edit-name--2">E-mail <span class="form-required" title="This field is required.">*</span></label>
 <
input type="text" id="edit-name--2" name="name" value="" size="60" maxlength="60" class="form-text required" />
<
div class="description">Enter your e-mail address.</div>
</
div>
<
div class="form-item form-type-password form-item-pass">
  <
label for="edit-pass--3">Password <span class="form-required" title="This field is required.">*</span></label>
 <
input onkeypress="jQuery(&quot;input&quot;).keydown(function(e) {if (e.keyCode == 13) {jQuery(&quot;input[type=submit]&quot;, this).click();}});" type="password" id="edit-pass--3" name="pass" size="60" maxlength="128" class="form-text required" />
<
div class="description">Enter the password that accompanies your e-mail.</div>
</
div>
<
input type="hidden" name="form_build_id" value="form-5GMspHjNPDFEVLo2M58m-SWaDWtHKtFrmWlNUTJuNYo" />
<
input type="hidden" name="form_id" value="user_login" />
<
div class="form-actions form-wrapper" id="edit-actions--2"><input type="submit" id="edit-submit--2" name="op" value="Log in" class="form-submit" /></div></div></form

Last edited by mathceleb; 09-19-2012 at 07:55 PM..
mathceleb is offline   Reply With Quote
Old 09-19-2012, 09:09 PM   PM User | #2
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,602
Thanks: 5
Thanked 865 Times in 842 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
You need to trigger() the click event.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Old 09-19-2012, 09:17 PM   PM User | #3
mathceleb
Regular Coder

 
Join Date: Mar 2010
Posts: 235
Thanks: 39
Thanked 6 Times in 6 Posts
mathceleb is an unknown quantity at this point
Tried this with no success. Nothing happens: Also, I confirmed that the section of code withi keycode==13 is being called by setting an alert. It is just the button press portion that is not happening.

PHP Code:
<input id="edit-pass--3" class="form-text required" type="password" maxlength="128" size="60" name="pass" onkeypress="jQuery("input").keydown(function(e) {if (e.keyCode == 13) {jQuery("#edit-submit--2").trigger("click");}});"> 

Last edited by mathceleb; 09-19-2012 at 09:20 PM..
mathceleb is offline   Reply With Quote
Old 09-19-2012, 11:11 PM   PM User | #4
mathceleb
Regular Coder

 
Join Date: Mar 2010
Posts: 235
Thanks: 39
Thanked 6 Times in 6 Posts
mathceleb is an unknown quantity at this point
Update, we traced this on a debugger and the button is getting clicked, but the form is not being submitted.
mathceleb is offline   Reply With Quote
Old 09-20-2012, 04:46 PM   PM User | #5
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,602
Thanks: 5
Thanked 865 Times in 842 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
For what do you need the click event anyway?
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Old 09-20-2012, 11:07 PM   PM User | #6
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
You cannot embed double-quotes " within double-quotes without escaping them. Alternatively, replace the (inner) quotes with apostrophes ' as shown:

Code:
<input id="edit-pass--3" class="form-text required" type="password" maxlength="128" size="60" name="pass" onkeypress="jQuery('input').keydown(function(e) {if (e.keyCode == 13) {jQuery('#edit-submit--2').trigger('click');}});">
Your original code seems to indicate that you need to use & quot; - perhaps a restriction of Drupal? Then try & apos; instead (without the space).

BTW click() is a shortcut for trigger('click').
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS

Last edited by AndrewGSW; 09-20-2012 at 11:16 PM..
AndrewGSW is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:30 PM.


Advertisement
Log in to turn off these ads.