Welcome Guest, Not a member yet? Register   Sign In
Custom validation callbacks trouble
#1

[eluser]Heyimjohn[/eluser]
First off, let me just say that I LOVE CodeIgniter and will be using it for every site I ever have to develop!

Now, on to the trouble I am having. I am trying to use custom callbacks to see if, for example, an email is already in use by another user or if a phone number matches a regular expression. Let me show you what I have in place right now:

Here I set the validation rules
Code:
$this->form_validation->set_rules('email', 'Email', 'required|trim|valid_email|max_length[128]|callback_check_email|xss_clean');

and here is the callback function
Code:
function check_email($str) {
        $query = $this->db->get_where('users', array('email' => $str));
        
        if($query->num_rows() > 0) {
            $this->form_validation->set_message('check_email', 'This email is already in use.');
            return false;
        } else {
            return true;
        }
    }

Its like CI is just ignoring the callback. This occurs for both the function above, and when I check the user's phone number against a regular expression. What am I doing wrong here?

Thanks!


Messages In This Thread
Custom validation callbacks trouble - by El Forum - 07-15-2010, 06:24 PM
Custom validation callbacks trouble - by El Forum - 07-16-2010, 01:42 AM
Custom validation callbacks trouble - by El Forum - 07-16-2010, 08:47 AM
Custom validation callbacks trouble - by El Forum - 07-16-2010, 12:35 PM
Custom validation callbacks trouble - by El Forum - 07-16-2010, 12:40 PM
Custom validation callbacks trouble - by El Forum - 07-16-2010, 12:43 PM
Custom validation callbacks trouble - by El Forum - 07-16-2010, 12:44 PM
Custom validation callbacks trouble - by El Forum - 07-16-2010, 01:03 PM
Custom validation callbacks trouble - by El Forum - 07-16-2010, 01:29 PM



Theme © iAndrew 2016 - Forum software by © MyBB