Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codeigniter form validation set message

A quick one guys, I have the same (ish) form validation rule for the username and email input fields respectively, and i need to set the message of the rules individually. How do i do that?

**CODE**

$this->form_validation->set_rules('username','Username', 'trim|required|xss_clean|min_length[2]|is_unique[users.username]');
$this->form_validation->set_rules('email','Email', 'trim|required|valid_email|xss_clean|is_unique[users.email]');

I'm trying to override the message for "is_unique" here,

$this->form_validation->set_message('is_unique','Username taken');

how do i set the message for email as well?

like image 611
Saff Avatar asked Apr 09 '26 13:04

Saff


1 Answers

$this->form_validation->set_message('is_unique', '%s is taken.');

%s is replaced with the "human name" you applied when setting the rule.

like image 120
Rick Calder Avatar answered Apr 12 '26 03:04

Rick Calder



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!