Page 1 of 1

Vaildation checkboxes

Posted: Mon Apr 14, 2008 1:39 pm
by tom_1
Hello ive got this code to check if a checkbox has been checked i want the user to at least check one checkbox, if they select none then an message should appear saying you havent selected any checkboxes. the user can only select up2 two checkboxes ive tried this code below and nothing is happening if any1 could help me plz :banghead:

Code: Select all

<script type="text/javascript">
function Check(){   
var checkSelected = false;  
for (i = 0;  i < document.Dates.checkbox.length;  i++)  
{   
if (document.Dates.checkbox[i].checked){        
checkSelected = true;       
}       
if (!checkSelected)     
{       
alert('You didn\'t choose any of the checkboxes!');     
return false;       
}   
}
}
</script>
 
<form name="Dates" action="send.php" method="post" onsubmit="return Check();">
 

Re: Vaildation checkboxes

Posted: Tue Apr 15, 2008 1:01 pm
by tom_1
still not working

Re: Vaildation checkboxes

Posted: Wed Apr 16, 2008 4:29 am
by aceconcepts
Can you show your form?