[eluser]PHPraja[/eluser]
Actually i got this count of empty array while validations using call back functions.
In my 'EmailToFriend' view i have a message box(text area), some list of dynamic check boxes(Friends list) and a textarea where the user can enter his friends emailid with a comma separated. Before submitting the form we should validate such that atleast one checkbox is checked or atleast one emailid is entered in the textarea. for this i used a CI validation as below using callback function.
Code:
$rules['emailslist']="callback_emailslist_check";
$rules['message']="required";
$this->validation->set_rules($rules);
$fields['emailslist'] = " Email List ";
$fields['message'] = " Message ";
$this->validation->set_fields($fields);
if ($this->validation->run() == FALSE)
{ redirect(place/placeemail); }
// This is a call back function
function emailslist_check($e)
{
if((count($this->input->post('chkEmails'))==1 ) && ($e==''))
{
//echo count($this->input->post('chkEmails')); die;
$this->validation->set_message('emailslist_check', 'At least one recipient is required');
return FALSE;
} else {
return TRUE;
}
}
In the above code 'emailslist' is the name of the textarea where the emailids should be entered and 'chkEmails' is the dynamic array (checkbox name ) This call back function does nt work. In the callback function can i check combination of two fields for validation? as i used above. I hope the above explanation is clear to express my doubt. any one plz help..