I have to validate that maximum 3 checkboxes are clicked. There are 11. How could I do this efficiently and without testing every possible situation?
+2
A:
You can do like this:
if (count($_POST['checkbox_name']) === 3)
{
// your code here.....
}
where your checkbox names should be suffixed with []
eg:
<input type="checkbox" name="checkbox_name[]" value="1" />
<input type="checkbox" name="checkbox_name[]" value="2" />
<input type="checkbox" name="checkbox_name[]" value="3" />
Sarfraz
2010-05-31 09:48:16