Hello.
I have a form validation assignment that I'm working on. On this form, I have a section that has 4 checkboxes. I'm trying to validate that at least one of the checkboxes has been selected. If not, then it displays an error message and doesn't submit (I've got this part handled).
The problem I'm having is that my loop is only checking for the first box option only and none of the others. I can't figure out why for the life of me.
Code:
function checkCheckedOpts(check_boxes, error){
for(var i=0; i < check_boxes.length;)
{
var ones_chkd = check_boxes[i++].checked;
if(!ones_chkd)
{error.val=5;return false;}
else
{return true;}
}
}
Firebug is showing that the variable 'check_boxes' has all of the options associated with it. Nothing wrong there. However, it's not looping through all of them to check if something was selected. 'ones_chkd' is only true if the first option is selected...why?...
|