用户
 找回密码
 入住 CI 中国社区
搜索
查看: 2244|回复: 3
收起左侧

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

[复制链接]
发表于 2011-7-14 18:05:38 | 显示全部楼层 |阅读模式
回调写在控制器里。但是不起作用,是怎么回事?
PHP复制代码
 
    function regist() {
        $this->form_validation->set_rules('username', '用户名', 'callback_username_check');
        $this->form_validation->set_rules('password', '密码', 'trim|required|min_length[6]|max_length[16]|matches[passconf]|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;
    }
 
复制代码
发表于 2011-7-14 18:33:41 | 显示全部楼层
不知道你在视图页面是否添加了
PHP复制代码
<?php echo validation_errors(); ?>
复制代码
 楼主| 发表于 2011-7-16 15:05:23 | 显示全部楼层
现在正常了。哪里都没动。。。郁闷。
发表于 2011-7-16 22:42:40 | 显示全部楼层
是浏览器缓存了你之前的代码把 哈哈

本版积分规则