[eluser]Thorpe Obazee[/eluser]
[quote author="mTuran" date="1242897527"]If i use validation callback as a private function which is _username_check, validation message convert to "Unable to access an error message corresponding to your field name.". If i convert validation callback to public everythings is ok but i have to use it as private function thanks.
Code:
$this->form_validation->set_rules('i_username2', 'lang:username', 'trim|required|min_length[4]|max_length[12]|xss_clean|callback__username_check');
Code:
function _username_check($username)
{
if (!$this->user->is_username_available($username))
{
$this->form_validation->set_message('username_check', $this->lang->line('not_available_resource'));
return FALSE;
}
if(preg_match('/[^A-Za-z0-9_$]/', $username))
{
$this->form_validation->set_message('username_check', $this->lang->line('valid_username'));
return FALSE;
}
return TRUE;
}
[/quote]
use
Code:
$this->form_validation->set_message('_username_check', $this->lang->line('valid_username'));
Code:
$this->form_validation->set_message('_username_check', $this->lang->line('not_available_resource'));