aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Form Submit on Hitting Enter key 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 "Form Submit on Hitting Enter key" Watch "Form Submit on Hitting Enter key" New topic
Author

Form Submit on Hitting Enter key

Abhinay Verma
Greenhorn

Joined: Dec 13, 2004
Posts: 24
Hi,
I have the following code


On pressing enter, the form doesn't submit. But if I remove one of input boxes, the form gets submitting.

Please suggest a solution to stop the form from getting submitted on pressing Enter key even when I have just one input box.

Thanks,
Abhinay
Balan Raj
Ranch Hand

Joined: Aug 26, 2003
Posts: 74
Add a hidden field !

Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
http://www.htmlcodetutorial.com/forms/index_famsupp_157.html
Abhinay Verma
Greenhorn

Joined: Dec 13, 2004
Posts: 24
Thanks to both of you for the quick response

Eric,
I had solved the problem using the keyCode. Was just wondering if there is some other way of fixing it. I guess window.event.keyCode is the only way of making it work

Balan,
The hidden field will not solve the problem.

Thanks & Regards,
Abhinay
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
you might be able to put

<form onsubmit="return true" ...........>

not sure if that would work.

Eric
Abhinay Verma
Greenhorn

Joined: Dec 13, 2004
Posts: 24
You are right Eric

The problem can be solved by using the onsubmit attribute of the form tag.

Thanks,
Abhinay
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Form Submit on Hitting Enter key
 
Similar Threads
servlets/jsp
Page reloading problem
Sequence of Parameters
urgent !!!!how to access contents of list in jsp
Problem in form submitting.