I am trying to validate my login form and I have rules on 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 on 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 the custom message that I want to display.
In my view, I want to individually show that check_database error. I don't want to show any of the other errors.
Here is what I have tried:
// does not work
<?php echo form_error('check_database'); ?>
// this works
<?php echo form_error('password'); ?>
so since it is for the Password field, it will only show when I echo the password errors. But that means, since password is a required field, if I don't type anything in it's going to display an error saying that the Password field is required.
Is there a way to only display my custom error message that I set?
callback_check_databaseand notcheck_database- gorelativedon't require the fieldspass everything directly to your callback - Gntem