Favorites

DOM HTMLFormElement: submit event

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
HTMLFormElement: submit event
DOM HTMLFormElement EventThis event is supported by all modern browsers.
Updated 28th November 2026

The submit event fires when a form is submitted, by a submit button, pressing Enter or requestSubmit(). It's the place to validate or send form data with JavaScript.

Description

The submit event fires on a <form> when it is submitted: by clicking a submit button, pressing Enter in a field, or calling requestSubmit(). It fires after the browser's built-in validation passes. Call event.preventDefault() to stop the page from navigating, then handle the data yourself, typically with new FormData(form) and fetch().

Listen for submit on the form rather than click on the button, so keyboard submission is handled too. event.submitter tells you which button was used. Calling form.submit() directly skips both validation and this event.

The submit event bubbles, so a listener on the document can handle every form on a page. If the browser's validation fails, the event doesn't fire and the browser shows its error messages instead; add novalidate to the form to handle validation yourself.

Syntax

form.addEventListener('submit', handler)

Example

<form id="f">
  <input name="email" type="email" required value="sam@example.com">
  <button name="action" value="save">Save</button>
  <button name="action" value="publish">Publish</button>
</form>
const form = document.getElementById('f');
form.addEventListener('submit', e => {
  e.preventDefault();
  const data = new FormData(form);
  console.log('Submitted by', e.submitter.value, 'with', Object.fromEntries(data));
});

Browser Support

The following information will show you the current browser support for the HTMLFormElement: submit event event. Hover over a browser icon to see the version that first introduced support for this event.

This event is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee