I run javascript when a form is submitted to check for empty fields. I use the same script for many sites. For some reason I am getting a error on one of my sites. The javascript stops, indicating a field is empty but it says it cannot take the focus because the element is either not visible or not enabled. I don't get this with any other site and the current site is a copy of another site which works fine. What could I have done wrong? If I try to display the current field ID, I get 0 returned. Here is the javascript.
for (i = 0; i < form.elements.length; i++) {
if (form.elements[i].type == "text" && form.elements[i].value == ""){
alert("All fields are required!");
form.elements[i].focus();
Go to the complete details ...