length 属性可返回表单中元素的数目。
formObject.length
下面的例子可返回表单中元素的数目:
<html>
<body>
<form id="myForm" method="get">
Name: <input type="text" size="20" value="Peter Griffin" /><br />
Text: <input type="text" size="20" value="Hello World" />
</form>
<script type="text/javascript">
document.write("Number of elements in myForm: ");
document.write(document.getElementById('myForm').length
);
</script>
</body>
</html>