Check box validation

Hi ive the below piece of code, which is displaying a checkbox for each record,
Im trying to validate it so if no checkboxes are checked I get an error message “you must select at least one checkbox”
im using CF8


 <td colspan="1" align="right"><input type="button" value="Send Invoices &raquo;" onclick="document.checkmail.submit();"></td>

any tips would be great

A javascript solution would be to set an integer variable isChecked and traverse all the input tags using a for loop. if the element.type = checkbox and element.checked= true, then add 1 to isChecked. if at the end of the loop isChecked > 0 then throw an error