Latest web development tutorials

HTML DOM Form length property

Form Object Reference Form Object

Definition and Usage

The length property returns the number of elements in the form.

grammar

formObject.length


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support length property


Examples

Examples

The following example returns the number of elements in the form of:

<html>
<body>

<form id="frm1" action="form_action.html">
First name: <input type="text" name="fname" value="Donald"><br>
Last name: <input type="text" name="lname" value="Duck"><br>
<input type="submit" value="Submit">
</form>

<script>
document.write(document.getElementById("frm1").length);
</script>

</body>
</html>

Examples of the above output:

3

try it"


Examples

More examples

Value obtained in the form of each element


Form Object Reference Form Object