Re: Javascript form validation (& checkboxes)

by "Alexander Feninga" <gassinaumasis(at)hotmail.com>

 Date:  Tue, 25 Jan 2000 00:02:32 PST
 To:  krone9(at)yahoo.com,
hwg-techniques(at)mail.hwg.org
  todo: View Thread, Original
>I've got a form which along with other fields has
>about 10 checkboxes of which the user is expected to
>pick one or more.
>
>I'd like the validation script to see if any
>checkboxes have been ticked and if so return true. If
>none of them have been ticked then return false. (and
>hence generate an alert saying tick a box!)

var boxes = new Array('names','of','check','boxes');

function validate()
{
var check = false;

for (i=0;i<boxes.length;i++)
{
   if (document.forms[0].elements[boxes[i]].checked)
   {
      check = true
   }
}

return check;
}

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA