HTML DOM Form length property
Definition and Usage
The length property returns the number of elements in the form.
grammar
formObject.length
Browser Support
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>
<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"
More examples
Value obtained in the form of each element
Form Object