Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Form Object

HTML DOM Form Object


Form Object

The Form object represents an HTML form.

In an HTML document,

A Form object is created each time a tag appears.

Forms are typically used to collect user data and contain input elements such as text fields, checkboxes, radio buttons, and submit buttons. A form can also contain select menus, textarea, fieldset, legend, and label elements.

Forms are used to send data to a server.


The Form object collects

W3C: W3C standard.

Union Description W3C
elements[] an array containing all the elements in the form. Yes

Form Object Properties

property Description W3C
acceptCharset The character set accepted by the server. Yes
action Sets or returns the action attribute of the form. Yes
enctype Sets or returns the MIME type used by the form to encode content. Yes
length Returns the number of elements in the form. Yes
method Sets or returns the HTTP method used to send data to the server. Yes
name Sets or returns the name of the form. Yes
target Sets or returns the name of the Frame or Window for the form submission result. Yes

Form Object Methods

Method Description W3C
reset() Resets a form. Yes
submit() Submits a form. Yes

Form Object Events

Events Description W3C
onreset Called before the form elements are reset. Yes
onsubmit Called before the form is submitted. Yes

Standard properties and events

The Form object also supports standard property and Events.