I have a number of search options and institutions which are selected by clicking on the checkbox to the side. How can I write some js to check that at least one institution has been selected?
I can do it using text boxes but can't seem to figure out how to check if a checkbox is empty..
collection=="" doesn't seem to work !!
Here is an example of one way you could do it:
<html>
<head>
<title>Form Text Fields Create and Validate</title>
<SCRIPT LANGUAGE="JavaScript">
// obj contains the form object.
function Valflds(obj)
{
count=0
len=obj.length // get the number of fields in the form
for(a=0;a<len;a++)
{
if(obj[a].type=="checkbox" && obj[a].checked) // only look at form elements that are checkbox type
{
count++ // count the number of checked boxes
}
}
if(count==0)
{
alert("You must check at least one text box! ")
return false // don't submit the form if no boxes are checked
}
Bookmarks