|
-
Sep 28th, 2001, 03:41 AM
#1
Thread Starter
New Member
Form Subit - JavaScript
I need assistance using JavaScript to run a JS function when a form is submitted. When the submit button is pressed, the form runs the function using the onClick method.
However, I also need this function to run when someone uses the 'Enter' key to submit the form, instead of pressing the 'Submit' button. Any assistance on how to do this would be much appreciated. Thanks!
-
Sep 28th, 2001, 03:57 AM
#2
Hyperactive Member
Include this function within Javascript tags...
Code:
function CaptureKey(theFormObj)
{
var key=window.event.keyCode;
if (key==13)
document.FormName.submit();
}
in each of the elements in the form add this attribute..
onkeypress='CaptureKey("Formname")'
For Ex:
<input type=text onkeypress='CaptureKey("LogForm")'>
- Jemima.
-
Sep 28th, 2001, 04:07 AM
#3
Thread Starter
New Member
Thanks for the prompt reply! I'll give it a shot, much appreciated.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|