HTMLFormElement: submit event

The submit event fires when a <form> is submitted.

Bubbles Yes (although specified as a simple event that doesn't bubble)
Cancelable Yes
Interface Event
Event handler property GlobalEventHandlers.onsubmit

Note that the submit event fires on the <form> element itself, and not on any <button> or <input type="submit"> inside it. (Forms are submitted, not buttons.)

The submit event only fires when the user clicks a submit button (<button> or <input type="submit">) in a form. The event is not raised when calling the form.submit() method directly.

Note: Trying to submit a form that does not pass validation triggers an invalid event. In this case, the validation prevents form submission, and thus there is no submit event.


This example uses EventTarget.addEventListener() to listen for form submit, and logs the current Event.timeStamp whenever that occurs, then prevents the default action of submitting the form.


<form id="form">
  <label>Test field: <input type="text"></label>
  <button type="submit">Submit form</button>
<p id="log"></p>


function logSubmit(event) {
  log.textContent = `Form Submitted! Time stamp: ${event.timeStamp}`;

const form = document.getElementById('form');
const log = document.getElementById('log');
form.addEventListener('submit', logSubmit);



Specification Status Comment
HTML Living Standard
The definition of 'submit' in that specification.
Working Draft No change
HTML 5.2
The definition of 'submit' in that specification.
Recommendation No change
HTML 5.1
The definition of 'submit' in that specification.
Recommendation No change
The definition of 'submit' in that specification.
Recommendation Initial definition

Browser compatibility

Update compatibility data on GitHub
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
submit eventChrome Full support YesEdge Full support YesFirefox Full support YesIE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes


Full support  
Full support

See also