Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

onkeyup function

 
Steve Dyke
Ranch Hand
Posts: 1629
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am calling a JS function from the onkeyup event of an input text box. When I hit the enter key in that box the form submits. How can I keep this from happening?
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the keycode, figure out the code for enter, use an if statemenet and learn about event bubbling http://www.quirksmode.org/js/events_order.html or use return false.

Eric
 
Steve Dyke
Ranch Hand
Posts: 1629
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is my JS function, again it works if the input text box is outside of my form tags but not if it is within the tags.

The keyCode = 13 and I have return false in my function.


[ December 02, 2008: Message edited by: Steve Dyke ]
 
Steve Dyke
Ranch Hand
Posts: 1629
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I could sure use some more help with this issue.
[ December 02, 2008: Message edited by: Steve Dyke ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64990
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read this.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64990
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does "doesn't work" mean in this case?
 
Steve Dyke
Ranch Hand
Posts: 1629
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry about not waiting. I finally figured out my problem. The input text box I was using did not have another control to lose focus too. I added another input text box, hid it, and it works fine.
 
steve claflin
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm still trying to figure out how your function works at all.

what you want is not:



but:


[ December 05, 2008: Message edited by: steve calflin ]
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also the code is not cross browser friendly.

should have a event in the arguments of the function, should be using window.event also.

Eric
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic