I am trying to use JavaScript to require that at least one one checkbox of multiple checkbox choices is selected. My validation works except that I need to add a "[]" to the checkbox name for separate server processing. Once I do that, my validation no longer works.
Here is my code:
When I use infocheckbox[] the validation does not work, but if I remove the [] and just use infocheckbox, it works just fine. Any idea on what I need to do to be able to use []?Code:<script type="text/javascript"> function formValidate(){ with(document.checkboxform){ checkSelected = false; for (i=0; i < infocheckbox[].length; i++) { if (infocheckbox[][i].checked){ checkSchool = true; } if (!checkSelected){ alert('Please choose at least one checkbox'); return false; } else { return true; } } } </script>





Bookmarks