CodeIgniter Forums
Validation - How to set differ error message for each required fields - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Validation - How to set differ error message for each required fields (/showthread.php?tid=11204)



Validation - How to set differ error message for each required fields - El Forum - 08-30-2008

[eluser]bonguoita[/eluser]
Hi all, I am very new to CI.

I have 2 fields need to validate: username and password. Both of them must be required.

How can I set a differ error message for each field?
For example, when username is empty, error message is : "Username must have"
and password is empty, error message is : "Password must have"

Now I only know to do this:
Code:
$customMessage = 'This is custom error message for required rule';
$this->validation->set_message('required', $customMessage)
And the string $customMessage always appear whenever a field is empty regardless it's username or password.

Please help me. Thank you!


Validation - How to set differ error message for each required fields - El Forum - 08-30-2008

[eluser]Colin Williams[/eluser]
[url="http://codeigniter.com/wiki/Custom_Validation_Errors_per_Field/ "]Try this[/url]