根据手册写表单验证回调,不起作用。
回调写在控制器里。但是不起作用,是怎么回事?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;
}
不知道你在视图页面是否添加了
<?php echo validation_errors(); ?> 现在正常了。哪里都没动。。。郁闷。 是浏览器缓存了你之前的代码把 哈哈
页:
[1]