SubmitEvent.submitter

The read-only submitter property found on the SubmitEvent interface specifies the submit button or other element that was invoked to cause the form to be submitted.

Syntax

let submitter = submitEvent.submitter;

Value

An element, indicating the element that sent the submit event to the form. While this is often an <input> element whose type or a <button> whose type is submit, it could be some other element which has initiated a submission process.

If the submission was not triggered by a button of some kind, the value of submitter is null.

Examples

In this example, a shopping cart may have an assortment of different submit buttons depending on factors such as the user's settings, the shop's settings, and any minimum or maximum shopping card totals established by the payment processors. Each of the submit elements' id is used to identify which payment processor the button corresponds to.

let form = document.querySelector("form");
form.addEventListener("submit", (event) => {
  let submitter = event.submitter;
  let handler = submitter.id;

  if (handler) {
    processOrder(form, handler);
  } else {
    showAlertMessage("An unknown or unaccepted payment type was selected. Please try again.", "OK");
  }
});

The handler ID is obtained by using the submit event's submitter property to get the submit button, from which we then get the ID. With that in hand, we can call a processOrder() function to handle the order, passing along the form and the handler ID.

Specifications

Specification Status Comment
HTML Living Standard
The definition of 'SubmitEvent.submitter' in that specification.
Living Standard

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
submitterChrome Full support 81Edge ? Firefox Full support 75IE ? Opera ? Safari ? WebView Android Full support 81Chrome Android Full support 81Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android No support No

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown