-3

我正在尝试为输入设置自定义消息:

$this->form_validation->set_message('username', 'Choose a business, Mang!');

并显示:

<?php echo form_error('username'); ?>

但是我什么都没有显示,怎么了?

这是我需要的吗?例子:

if($result)
{
    $this->form_validation->set_message('username', 'Choose a business, Mang!');
}
4

1 回答 1

0

You need to set rules as such:

$this->form_validation->set_rules('form_field_username', 'username', 'required|callback_business_check');

function business_check($username) {
    if(strlen($this->input->post('form_field_business')) == 0) {
        $this->form_validation->set_message('business_check', 'Choose a business, Mang!');
        return false;
    }
    return true;
}

This is providing I have the right idea of what you are doing...

于 2013-05-08T10:40:44.543 回答