I need a bit of help validating a form to make sure that at least one checkbox was selected before the form is submitted. The prpoblem I've got though is that each checkbox has to have a value such as:

name="checkbox[]" (because it's used to pass values to another PHP page.)

I''ve come up with the following code so far which works fine if the checkboxes do not have the additional '[]'s after the name... but it doesn't work in this current state:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function valid()
var i;
var isValid = false;
for (i = 0; i < document.the_form.checkbox.length; i++) {
if(document.the_form.checkbox[i].checked == true) {
isValid = true;
if (!isValid) {
alert("You must select at least one option to continue.");
return false;

<form name="the_form" onsubmit="return valid();">
<tr><td><input type="submit" value="Create Record" /></td></tr>
<tr><td> </td></tr>
<td>Check box 1</td>
<td><input type="checkbox" value="1" name="checkbox[]" /></td>
<td>Check box 2</td>
<td><input type="checkbox" value="2" name="checkbox[]" /></td>
<td>Check box 3</td>
<td><input type="checkbox" value="3" name="checkbox[]" /></td>


Any help on getting this working would be really appreciated