Codeigniter表单验证集规则

时间:2016-10-07 13:11:37

标签: php

我遇到此代码的问题:

$this->form_validation->set_rules('username', 'Username', 'trim|required|min_length[4]|callback_user_check'); 

即使用户名字段为空,它也会显示user_check错误;我期待所需的错误消息。

function username() {
    $query = "SELECT salt FROM user WHERE username = ?";
    $get_query = $this->db->query($query, array($this->username));
    if ($get_query->num_rows() > 0) {
        $row = $get_query->row_array();
        return $row['salt'];
    } else {
        return false;
    }
}

1 个答案:

答案 0 :(得分:0)

设置验证自定义消息

$this->form_validation->set_message('username', 'Your message here');