Just trying to figure out my error of "strange loop". I receive this error in JSLint and the loop just keeps going over and over again whereas it needs to stop.
<script type="text/javascript">
function checkForm(theForm) {
"use strict";
/*global alert*/
var formValid = true,
elementCount = 0;
while (elementCount <= theForm.length) {
if (theForm.elements[elementCount].type === "text") {
if (theForm.elements[elementCount].value() === "") {
alert("Please complete all the form elements");
theForm.elements[elementCount].focus();
formValid = false;
break;
}
}
return formValid;
}
} </script>
Any help or guidance is appreciated, please explain or show me as I am a novice.