File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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: 1446
    
    1
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: 1446
    
    1
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: 1446
    
    1
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: 61218
    
  66

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: 61218
    
  66

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

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