2011-04-12 110 views
0

我想在我的项目中获取两个表单验证运行语句。首先,我想检查我的选择框值。如果它的空间,那么我收到一条错误消息。在这里我也想要验证如果选择框的值是'其他',然后我想检查文本框中的值。可能吗。 也就是说,我想要执行两个表单验证运行语句。如果第一个运行语句为真,我必须检查第二个运行语句。多个表单验证运行语句

+0

请提供更多详细信息,例如您的验证码,您想要的确切输出 – jimy 2011-04-12 12:08:12

回答

0

没有理由不能设置一些规则,运行验证,然后设置更多的规则,然后再次运行验证。

$this->load->library('form_validation'); 
$this->form_validation->set_rules('username', 'Username', 'required'); 
if ($this->form_validation->run() == FALSE) { 
    // Do whatever you do on fail 
} else { 
    $this->form_validation->set_rules('email', 'Email', 'required'); 
    if ($this->form_validation->run() == FALSE) { 
     // do whatever you do on the 2nd fail 
    } 
    // do whatever you do on success 
}