[eluser]benshepherd283[/eluser]
Hello,
Before I state my problem, I would like to say that I started learning CodeIgniter yesterday so apologies in advance if I make myself look stupid
I have a model that I am using to check inputted information when a user signs up and I would like a callback function that checks if the username contains symbols but for some odd reason, I can't seem to get the callback function to work. I can't get it to be called
Here's my code:
Code:
public function create() {
$this->init();
$this->load->library('form_validation');
$this->form_validation->set_rules('username','Username','required|min_length[3]|max_length[16]|is_unique['.$this->table.'.username]|trim|xss_clean|callback_validate_username');
$this->form_validation->set_rules('password','Password','required|min_length[6]');
$this->form_validation->set_rules('passconf','Password confirmation', 'required|min_length[6]');
return $this->form_validation->run();
}
public function validate_username($username) {
die("DEBUG"); //so I can see if it has been called
if(!preg_match("/^[a-zA-Z0-9]+$/", $username)) {
$this->form_validation->set_message('validate_username', 'Username must not contain symbols');
return false;
}
return true;
}