Difference between revisions of "JavaScript onsubmit"
From Market Ruler Help
(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…') |
|||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
In a web page's [[HTML]], a web developer can use [[JavaScript]] to trigger client-side code to track when a form is submitted. | 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> | + | The '''<form>''' [[HTML]] tag appears like so: |
<code><form action="''url to submit to''" method="post"><br /> | <code><form action="''url to submit to''" method="post"><br /> | ||
Line 15: | Line 15: | ||
The change appears like: | The change appears like: | ||
− | <code><form action="''url to submit to''" method="post" onsubmit="return | + | <code><form action="''url to submit to''" method="post" onsubmit="return __CR.submit(this, '8')"><br /> |
<input type="text" name="email" value="" /><br /> | <input type="text" name="email" value="" /><br /> | ||
<input type="submit" name="subscribe" value="Subscribe" /><br /> | <input type="submit" name="subscribe" value="Subscribe" /><br /> |
Latest revision as of 15:47, 26 February 2016
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(this, '8')">
<input type="text" name="email" value="" />
<input type="submit" name="subscribe" value="Subscribe" />
</form>