wood burning stoves*
The moose likes HTML, CSS and JavaScript and the fly likes onkeyup function Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "onkeyup function" Watch "onkeyup function" New topic
Author

onkeyup function

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1393
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
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

Joined: Nov 16, 2004
Posts: 1393
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

Joined: Nov 16, 2004
Posts: 1393
I could sure use some more help with this issue.
[ December 02, 2008: Message edited by: Steve Dyke ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

Please read this.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

What does "doesn't work" mean in this case?
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1393
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

Joined: Dec 04, 2008
Posts: 54
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: onkeyup function
 
Similar Threads
textbox cursor
Delay while I type characters in the text box
Find duplicate value in jsp page
How to create a Tabbed page....Help...Urgent....
Hiding a popup span with onblur