Finding Forms in HTML Page using javascript

Manideepgoud
Posted by Manideepgoud under JavaScript category on | Points: 40 | Views : 1136
We can find how many form element we are using in a HTML page using document.forms.length by using JavaScript DOM ELEMENTS.
<form>
FirstName: <input type="text" />
</form><br />
<form>
LastName:<input type="password" />
</form>
<p id="demo"></p>
<script>
document.getElementById('demo').innerHTML = "Number of Forms in the page :" + document.forms.length;
</script>

Here we have taken two forms in the page , so it displays 2 in the output

OUTPUT
Number of forms in the page:2

Comments or Responses

Login to post response