In my view page.I have a 10 textboxes for entering value, common name for all 10 fields that is 'value'. In my CodeIgniter validation that prevent only | character.
for($i=1;$i<=10;$i++)
{
$value[$i]=$this->input->post('value'.$i);
if ( !empty($value[$i]))
{
$this->form_validation->set_rules('value'.$i, 'Value', 'required|callback_Eventvalue['.$i.']');
}
}
And my call back function shown below
public function Eventvalue($i)
{
echo $i;
if ( preg_match('|', $i));
{
$this->form_validation->set_message('Eventvalue', 'The %s field may not contain '|' character');
}
}
My for loop is working. I get each value inside the function. But the condition is not working.