Name
HTMLFormElement — a <form> in an HTML document
Availability
DOM Level 1 HTML
Inherits from/Overrides
Node → Element → HTMLElement → HTMLFormElement
Properties
-
readonly
HTMLCollection
elements
An array (HTMLCollection) of all elements in the form.
-
readonly long length
The number of form elements in the form. This is the same value as
elements.length
.
In addition to the properties above, HTMLFormElement also defines the properties in the following table, which correspond directly to HTML attributes.
Property |
Attribute |
Description |
---|---|---|
|
|
Character sets the server can accept |
|
|
URL of the form handler |
|
|
Encoding of the form |
|
|
HTTP method used for form submission |
|
|
Name of the form |
|
|
Frame or window name for form submission results |
Methods
-
reset( )
Resets all form elements to their default values.
-
submit( )
Submits the form.
Description
This interface represents a <form>
element
in an HTML document. The elements
property is an
HTMLCollection that provides convenient access to all elements of the
form. The submit( )
and reset( )
methods allow a form to be submitted or reset under
program control.
See the Form object in the client-side reference section for more details.
See Also
Form object in the client-side reference section
Type of
HTMLButtonElement.form, HTMLFieldSetElement.form, HTMLInputElement.form, HTMLIsIndexElement.form, ...
Get JavaScript: The Definitive Guide, Fourth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.