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 submitting form when 'enter' is hit 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 "submitting form when Watch "submitting form when New topic
Author

submitting form when 'enter' is hit

Anthony Leroy
Greenhorn

Joined: Aug 02, 2001
Posts: 20
How do I stop the form from submitting when enter is hit?
OR how do I call a javascript function when enter is hit in a form field?
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
Anthony
To call a javascript function use this in your form tag:
<form name='myForm' onsubmit='return jsFunction();'>
Then have your function return true or false if its ok or not ok to submit it. If you return false the form isn't submitted and you can display an alert box or something else to the user to fix whatever's wrong and try again.
hope that helps

------------------
Dave
Sun Certified Programmer for the Java� 2 Platform


Dave
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: submitting form when 'enter' is hit