Codeigniter中的任一类型验证?
我有两个控件,一个是下拉列表(CMBCegories),另一个是输入文本框(TXTCegority) 现在,我想添加验证。如果未从CMBCegories下拉列表中选择Category,它将查找txtCategory文本框如果两者都不存在,则应给出一个错误只需说“您必须从下拉列表中选择类别或进入类别文本框” 我使用了以下类型验证规则,但它给出了意外的结果Codeigniter中的任一类型验证?,codeigniter,validation,Codeigniter,Validation,我有两个控件,一个是下拉列表(CMBCegories),另一个是输入文本框(TXTCegority) 现在,我想添加验证。如果未从CMBCegories下拉列表中选择Category,它将查找txtCategory文本框如果两者都不存在,则应给出一个错误只需说“您必须从下拉列表中选择类别或进入类别文本框” 我使用了以下类型验证规则,但它给出了意外的结果 $this->form_validation->set_rules('cmbCategories','Category','requ
$this->form_validation->set_rules('cmbCategories','Category','required|is_natural|xss_clean');
$this->form_validation->set_rules('txtCategory','Category','required|min_length[5]|xss_clean');
我如何实现我想要的功能?CI的验证方法只能在单个输入上调用,因此我认为您无法单独使用它们来完成您要做的事情。我只需要检查提交的post变量,确保它们都不是空的
if ($this->input->post('cmbCategories') == 0 && $this->input->post('txtCategory') == '')
{
// set error message and stop processing
}