<form>
HTML DOM Form object
Form object
The Form object represents an HTML form.
A Form object is created each time <form> appears in an HTML document.
Form users are usually used to collect user data and contain input elements. Such as: text fields, checkboxes, radio buttons, submit buttons, etc. Forms can also have options menu, textarea, fieldset, legend, and label elements.
Forms are used to send data to the server.
Form object collection
W3C: W3C standard.
Collection | Description | W3C |
---|---|---|
elements[] | An array containing all the elements in the form. | Yes |
Form object attributes
Attribute | Description | W3C |
---|---|---|
acceptCharset | The character set acceptable to the server. | Yes |
action | Sets or returns the action property of the form. | Yes |
enctype | Sets or returns the MIME type that the form uses to encode the content. | Yes |
length | Returns the number of elements in the form. | Yes |
method | Sets or returns an HTTP method that sends data to the server. | Yes |
name | Sets or returns the name of the form. | Yes |
target | Sets or returns the Frame or Window name of the form submission result. | Yes |
Form object methods
Method | Description | W3C |
---|---|---|
reset() | Reset a form. | Yes |
submit() | Submit a form. | Yes |
Form object events
Event | Description | W3C |
---|---|---|
onreset | Called before resetting form elements. | Yes |
onsubmit | Called before the form is submitted. | Yes |
Standard Properties and Events
Form objects also support standard properties and events .