Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within HTML Pages with CSS and JavaScript
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
paul wheaton
Jeanne Boyarsky
Ron McLeod
Sheriffs:
Paul Clapham
Liutauras Vilda
Devaka Cooray
Saloon Keepers:
Tim Holloway
Roland Mueller
Bartenders:
Forum:
HTML Pages with CSS and JavaScript
Form Submit on Hitting Enter key
Abhinay Verma
Greenhorn
Posts: 24
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi,
I have the following code
<form name="myForm" action="http://www.yahoo.com" method="post"> <table> <tr> <td> <input type="text" name="txtMyTextBox" value=""> <input type="text" name="txtMyTextBox1" value=""> </td> </tr> </table> </form>
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
Posts: 74
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Add a hidden field !
form name="myForm" action="http://www.yahoo.com" method="post"> <table> <tr> <td> <input type="text" name="txtMyTextBox" value=""> <input type="hidden" name="txtMyTextBox1" value=""> </td> </tr> </table> </form>
Eric Pascarello
author
Posts: 15385
6
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
http://www.htmlcodetutorial.com/forms/index_famsupp_157.html
Abhinay Verma
Greenhorn
Posts: 24
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
Posts: 15385
6
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
you might be able to put
<form onsubmit="return true" ...........>
not sure if that would work.
Eric
Abhinay Verma
Greenhorn
Posts: 24
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
You are right Eric
The problem can be solved by using the onsubmit attribute of the form tag.
Thanks,
Abhinay
Nothing up my sleeve ... and ... presto! A tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
servlets/jsp
Page reloading problem
Sequence of Parameters
urgent !!!!how to access contents of list in jsp
Problem in form submitting.
More...