Vaildation checkboxes

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tom_1
Forum Newbie
Posts: 5
Joined: Mon Apr 14, 2008 1:21 pm

Vaildation checkboxes

Post 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();">
 
tom_1
Forum Newbie
Posts: 5
Joined: Mon Apr 14, 2008 1:21 pm

Re: Vaildation checkboxes

Post by tom_1 »

still not working
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: Vaildation checkboxes

Post by aceconcepts »

Can you show your form?
Post Reply