problem validating checkbox

Giganews Newsgroups
Subject: problem validating checkbox
Posted by:  Peter B. Ensch (peter…
Date: Thu, 10 Jul 2003

Can anyone explain why this code fails when the set of checkboxes
consists of only one.

myForm.update.length returns 0 instead of 1 with the result that
I get an alert box even tho' the one checkbox is checked.


function checkForm(myForm) {
  var numBoxes = 1*myForm.update.length || 0;
  for(i=0;i<numBoxes;i++) {
    if(myForm.update[i].checked == true)
      return true;
    alert("Select one or more part components to update");
    return false;