Form.elements.length (Property)

The number of input elements there are in the form. This is a reflection of the Form.length property.

Availability:

DOM level - 1
JavaScript - 1.0
JScript - 1.0
Internet Explorer - 3.02
Netscape - 2.0
Opera - 3.0
Property/method value type:Number primitive
JavaScript syntax:-myForm.elements.length

Form.elements.length is not really a property of the Form object but it is convenient to discuss it here since it is related to the Form.length property.

The structural model of the form and its length property is somewhat confusing because there is an elements[] collection which is really what is being measured. Somehow, the elements all being members of the Form object, means that the Form object's length value is really the length value of the elements[] collection.

The elements collection is really a reference to the Form object and this means the elements collection is polluted with a lot of associatively named member items that are not actually form elements at all.

It is possible that future browser versions will correct this and that a proper FormElementArray class is created. For legacy reasons, the Form.length parameter may need to persist.

See also:Collection.length, Form.length, FormElement object, length

Property attributes:

readonly