Validation - How to set differ error message for each required fields

#1
[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!

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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.