Forms are the HTML elements created inside a <form> … </form> tag. They are used for filling forms used with in variety of applications, a user login, bank details windows …etc. The form elements can be referenced in JavaScript for manipulation directly or as an array.

The properties and methods available to manipulate forms in JavaScript are:

The properties and methods available to manipulate forms in JavaScript are

Method/Properties

Description

method

METHOD attribute of HTML form which takes get or post as property.

elements

Returns a collection of element in the form.

acceptCharset

Sets or resets the accept-charset attribute which refers to the character-sets that can be used to fill form.

action

Specifies the action that has to be taken on filling the form like, where to send the form data on submission.

autocomplete

String which sets the autocomplete to browser on/off. When it is ‘on’ browser automatically fills the value of the form based on the input values before.

enctype

String which represents the ‘enctype’ HTML attribute. It indicates the type of content that is used to transmit form to server. By default, "application/x-www-form-urlencoded" format is used where empty spaces are filled with ‘+’ and special characters to ASCII HEX values.

length

Number of elements in form.

name

Sets or returns name attribute in a form.

noValidate

If this Boolean is set, the form is validated

target

Specifies name where to display the response after submitting the form. Values can be _blank, _self, _parent, _top or framename.

reset()

This method resets all elements in the form.

submit()

This method submits the form.

 

›› go to examples ››