JavaScript onsubmit

From Market Ruler Help
Revision as of 13:23, 4 November 2010 by Admin (talk | contribs) (Created page with 'In a web page's HTML, a web developer can use JavaScript to trigger client-side code to track when a form is submitted. The '''<form>" HTML tag, appears like s…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

In a web page's HTML, a web developer can use JavaScript to trigger client-side code to track when a form is submitted.

The <form>" HTML tag, appears like so:

<form action="url to submit to" method="post">
    <input type="text" name="email" value="" />
    <input type="submit" name="subscribe" value="Subscribe" />
</form>

The onsubmit attribute can be added to the form tag, and the value contains the JavaScript to run when the user:

  • Presses the Enter key on their keyboard, or
  • Presses the input element which is of type "submit" (here, "Subscribe" button)

The change appears like:

<form action="url to submit to" method="post" onsubmit="return cr_submit('8')">
    <input type="text" name="email" value="" />
    <input type="submit" name="subscribe" value="Subscribe" />
</form>

For more information