√__豿艉騲℡ 发表于 2011-7-14 18:05:38

根据手册写表单验证回调,不起作用。

回调写在控制器里。但是不起作用,是怎么回事?

    function regist() {
      $this->form_validation->set_rules('username', '用户名', 'callback_username_check');
      $this->form_validation->set_rules('password', '密码', 'trim|required|min_length|max_length|matches|md5');
      $this->form_validation->set_rules('passconf', '确认密码', 'trim|required');
      if ($this->form_validation->run() == FALSE) {
            $this->load->view('registration_view');
      } else {
            if ($this->User_model->regist()) {
                echo '注册成功';
            } else {
                echo '注册失败';
            }
      }
    }
   
    function username_check($str) {
      $this->form_validation->set_message('username_check', 'test');
      return FALSE;
    }

binbin 发表于 2011-7-14 18:33:41

不知道你在视图页面是否添加了
<?php echo validation_errors(); ?>

√__豿艉騲℡ 发表于 2011-7-16 15:05:23

现在正常了。哪里都没动。。。郁闷。

無銘份的浪漫 发表于 2011-7-16 22:42:40

是浏览器缓存了你之前的代码把 哈哈
页: [1]
查看完整版本: 根据手册写表单验证回调,不起作用。