I am trying to verify my registration form and I have rules in my Username and Password fields.
$this->form_validation->set_rules('username', 'Username', 'trim|required|xss_clean'); $this->form_validation->set_rules('password', 'Password', 'trim|required|xss_clean|callback_check_database');
So, my callback_check_database function is in the Password field.
So, in my function for check_database, I have:
$this->form_validation->set_message('check_database', 'Invalid username or password'); return false;
So, I am setting up a custom message that I want to display.
In my opinion, I want to individually show this check_database error. I do not want to show any other errors.
Here is what I tried:
// does not work <?php echo form_error('check_database'); ?> // this works <?php echo form_error('password'); ?>
since it is intended for the Password field, it will only be displayed when I repeat the password errors. But this means that since the password is a required field, if I do not find anything in it, an error will be displayed indicating that the Password field is required.
Is there a way to display only my custom error message?
source share