[eluser]Twisted1919[/eluser]
If you know for sure your number of checkboxes, do a for() loop, no problem with this.
But i would use arrays so instead of <input name="a1" /><input name="a2" /> i would use
<input name="a[]" />, then i wouldn't validate this array at all in the form_validation rules, instead, i would do it after the validation has passed, something like:
Code:
if($this->form_validation->run())
{
if(isset($_POST['a'])&&is;_array($_POST['a']))
{
$a=$_POST['a'];
$a=$this->security->xss_clean($a);
foreach($a AS $key=>$value)
{
if(empty($value)||strlen($value)>255)
{
//trigger error.
}
}
}
else
{
//trigger error: come one, check something...
}
}