Form lengthProperty

Form 对象参考手册Form Object

Definition and Usage

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

Syntax

formObject.length


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the length property.


Example

Example

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

<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>

The output of the above example is:

3

Try it Yourself »


实例

More Examples

Get the value of each element in the form


Form 对象参考手册Form Object Other Extensions