Results 1 to 3 of 3

Thread: Form Subit - JavaScript

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2001
    Posts
    2

    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!

  2. #2
    Hyperactive Member
    Join Date
    Aug 2001
    Location
    India
    Posts
    276
    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.

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2001
    Posts
    2
    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
  •  



Click Here to Expand Forum to Full Width