在我的视图页面中。我有10个文本框用于输入值,所有10个字段的常用名称是' value'。在我的CodeIgniter验证中,仅防止|字符。
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.']');
}
}
我的回叫功能如下所示
public function Eventvalue($i)
{
echo $i;
if ( preg_match('|', $i));
{
$this->form_validation->set_message('Eventvalue', 'The %s field may not contain '|' character');
}
}
我的for循环工作正常。我在函数中得到每个值。但条件不起作用。