谢谢两位,问题依旧啊,我的代码如下:
function reg(){
$this->load->helper('form');
$this->load->library('form_validation');
$this->form_validation->set_rules('idno', 'idno', 'required|callback_idno_check');
if ($this->form_validation->run($rules) == FALSE){
$this->load->view('reg.html');
}
else{
$this->load->view('regsuccess.html');
}
function idno_check($str)
{
if ($str == 'test')
{
$this->form_validation->set_message('idno_check', 'The %s field can not be the word "test"');
return FALSE;
}
else
{
return TRUE;
}
}
}
顺便贴上我的扩展代码:
MY_Form_validation类
class MY_Form_validation extends CI_Form_validation{
public function MY_Form_validation(){
parent::CI_Form_validation();
}
public function idno_check($str)
{
if ($str == 'test')
{
return FALSE;
}
else
{
return TRUE;
}
}
}
form_validation_lang.php
$lang['idno_check'] = "The %s field can not be the word 'test'"