ZhouYY 发表于 2020-5-19 10:54:38

表单验证的顺序

本帖最后由 ZhouYY 于 2020-5-20 09:40 编辑

$this->form_validation->set_rules("add_ctitle", "所属机房", "trim|required|callback_ctitle_check");
$this->form_validation->set_rules("add_name", "名称", "trim|required|callback_name_check");
$this->form_validation->set_rules("add_tezhu", "特注", "trim|in_list");
$this->form_validation->set_rules("add_cata2", "籍别", "trim|required|callback_cata2_check");
$this->form_validation->set_rules("add_cata1a", "县市", "trim|required|callback_cata_all_check");
$this->form_validation->set_rules("add_didian", "地点", "trim|required|callback_cata4_check");


上面是我的验证规则


public function ctitle_check($id)
    {
      $count = $this->Pub_mod->count("member", array("menu_id" => 23, "mem_account" => $id));
      if (empty($count)) {
            $this->form_validation->set_message("ctitle_check", "输入机房不存在");
            return FALSE;
      } else {
            return TRUE;
      }
    }


上面是我的callback

如果我规则里面有"required"不管有填写没有填写,一样都只会显示callback的错误讯息。
感觉callback是最大的,前面的规则都排在他后面。
这个有解吗?









页: [1]
查看完整版本: 表单验证的顺序