Favorites

DOM HTMLFormElement Interface

☕
Enjoying this site?

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

Buy us a coffee
HTMLFormElement
DOM InterfaceThis interface is supported by all modern browsers.
Updated 28th November 2026

HTMLFormElement represents a form element. It gives access to the form's controls and lets you submit, reset and validate it from JavaScript.

Description

The HTMLFormElement interface represents a <form> element. It provides access to its controls through elements, and methods to submit(), requestSubmit(), reset(), checkValidity() and reportValidity(). Attributes such as action, method and noValidate are reflected as properties.

The submit event lets you validate or send data with fetch() instead of loading a new page. new FormData(form) collects every named field's value in one step.

Form submission also happens when the user presses Enter in a text field, as long as the form has a submit button, so handling the submit event covers both mouse and keyboard users. requestSubmit() behaves like a click on a submit button, running validation and firing submit, while the older submit() method skips both.

Inheritance

HTMLFormElement inherits properties and methods from HTMLElement.

Properties

NameDescription
HTMLFormElement.elementsThe elements property returns all the controls in a form, which can be looked up by name or index.

Methods

NameDescription
HTMLFormElement.checkValidity()The checkValidity() method checks whether every field in a form passes its validation rules.

Events

NameDescription
HTMLFormElement: submit eventThe submit event fires when a form is submitted, by a submit button, pressing Enter or requestSubmit().

Example

<form id="signup">
  <input name="email" type="email" value="sam@example.com">
  <input name="plan" value="pro">
  <button>Sign up</button>
</form>
const form = document.getElementById('signup');
form.addEventListener('submit', e => {
  e.preventDefault();
  const data = Object.fromEntries(new FormData(form));
  console.log('Would send:', data);
});
console.log(form.elements.length, form.elements.email.type);
form.requestSubmit();

Browser Support

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

This interface 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