...

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



a_user
06-09-2010, 03: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;
}
}


onkeypress="checkUsernameForLength(this);"

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] != "") {
i++;
document.form.submit();
}
}
}


onclick="verifyit()"

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.

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

there is also a problem with your submit logic …



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum