Ex1 1
Ex1 1
Checkboxes,
and so on). Write JavaScript code to count the number of elements in a
form.
< html>
<head>
<title> Count form elements </title>
<script type="text/javascript">
function countFormElements()
{
alert("the number of elements are :"+document.myForm.length);
}
</script>
</head>
<body bgcolor=cyan>
<h1 align=center>Counting Form Elements </h1>
<hr>
<form name="myForm" align=left>
1. Name :     <input type=text/> <br><br>
2. Password: <input type="password"/><br><br>
3. Address:  <textarea id="emailbody" cols=50 rows=10></textarea>
<br><br>
4. Sex:<input type=radio name=gender/>Male
<input type=radio name=gender/>Female<br><br>
5. Newsletter <input type=checkbox checked="checked"/><br><br>
<input type=button value="Send Message" onclick="countFormElements()" />
</form>
</body>
</html>