DOM HTMLFormElement Interface
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
| Name | Description |
|---|---|
HTMLFormElement.elements | The elements property returns all the controls in a form, which can be looked up by name or index. |
Methods
| Name | Description |
|---|---|
HTMLFormElement.checkValidity() | The checkValidity() method checks whether every field in a form passes its validation rules. |
Events
| Name | Description |
|---|---|
HTMLFormElement: submit event | The submit event fires when a form is submitted, by a submit button, pressing Enter or requestSubmit(). |
Example
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.
Desktop





Tablets & Mobile





