Custom error message using CodeIgniter Form Validation
This is how you set a message error ONLY for username:
$this->form_validation->set_rules('username','Username','is_unique',array('is_unique' => 'The %s is already taken'));
create a **form_validation.php** file and use this method:
"add_user_rule" => [
[
"field" => "username",
"label" => "Username",
"rules" => "required|trim|is_unique[users.username]",
"errors" => [
'is_unique' => 'The %s is already taken.',
],
],
],
Thank You
Right way of doing this is by passing a string format
$this->form_validation->set_message('is_unique', 'The %s is already taken');
So, then only we can able to get message like "This Username is already taken"
or "This Email is already taken"
.