CodeIgniter Forums
Custom Error Messages for each Validated Form Element - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Custom Error Messages for each Validated Form Element (/showthread.php?tid=5437)



Custom Error Messages for each Validated Form Element - El Forum - 01-21-2008

[eluser]Eric Cope[/eluser]
I know there is a way of setting custom error messages for validation rules (i.e. required, trim, etc.) However, is there a way of creating custom error messages for form elements? I know I can create custom callback functions, one for each form element, and then emed all the rules in it, but that does not seem as elegant as CI typically is. Any ideas are welcome.


Custom Error Messages for each Validated Form Element - El Forum - 01-21-2008

[eluser]ekeretex[/eluser]
You can edit (or add to) the validation language file (system/language/{language}/validation_lang.php).

Alternatively you could overide the error message in the controller. This works:
Code:
$this->validation->_error_messages['required'] = "You forgot to type the %s";