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.

elements[]An array containing all the elements in the form.Yes

Form object attributes

acceptCharsetThe character set acceptable to the server.Yes
actionSets or returns the action property of the form.Yes
enctypeSets or returns the MIME type that the form uses to encode the content.Yes
lengthReturns the number of elements in the form.Yes
methodSets or returns an HTTP method that sends data to the server.Yes
nameSets or returns the name of the form.Yes
targetSets or returns the Frame or Window name of the form submission result.Yes

Form object methods

reset()Reset a form.Yes
submit()Submit a form.Yes

Form object events

onresetCalled before resetting form elements.Yes
onsubmitCalled before the form is submitted.Yes

Standard Properties and Events

Form objects also support standard properties and events .