Reputation: 103
I'm currently trying to find a way to only display specific errors of an error list.
$this->form_validation->set_rules('password', 'lang:user.password', 'trim|required|min_length[6]|max_length[12]|matches[password_confirm]');
I want to be able to show a message if the field is empty like "Some fields are missing". But I want to show a specific message if the user only write a password shorther than 6 characters or higher than 12 like "The password length must be between 6 and 12 characters"
Thx.
Upvotes: 0
Views: 165
Reputation: 115
Once you've set your rules, you simply make sure that you include
<?php echo validation_errors(); ?>
somewhere in your form.
You can also show an individual error using something like this:-
<?php echo form_error('password'); ?>
More info here:- Form Validation : CodeIgniter User Guide
Upvotes: 0
Reputation: 2008
I encourage you to read the documentation. You can :
Dynamically set error messages with :
$this->form_validation->set_message('required', '%s must not be empty.');
$this->form_validation->set_message('min_length', '%s must be between 6 and 12 characters.');
$this->form_validation->set_message('max_length', '%s must be between 6 and 12 characters.');
Upvotes: 4