View Full Version : Javascript's "while" loop in function, have an error somewhere.

06-09-2010, 04:50 AM
First post here so...

I have a few functions called by a form. Two examples are onclick in a form input and onkeyup in a form button.

function checkUsernameForLength(whatYouTyped) {
var fieldset = whatYouTyped.parentNode;
var txt = whatYouTyped.value;
if (txt.length > 2) {
fieldset.className = "welldone";
return true;
else {
fieldset.className = "";
return false;


There are a couple of the above "validation" functions. Each sets an input fieldset's class.

function verifyit() {
var fieldsets = document.getElementsByTagName("fieldset");
var i=0;
while (i<count(fieldsets)){
if (fieldsets[i] != "") {


The function above is where I'm having the trouble. I want to iterate through the fieldsets and make sure each class isn't blank before allowing the button to submit the form. I get an "object expected" error when I trigger the "verifyit" function with ie if it helps.

I appreciate any input, thanks in advance for any help.

06-09-2010, 05:53 AM
which line exactly throws that error?

there is also a problem with your submit logic …