CodeIgniter Forums

Full Version: Editi validation errors style
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Evollution[/eluser]
How can i edit validation errors style ?

El Forum

[eluser]InsiteFX[/eluser]
This is in the CodeIgniter User Guide!
Code:
Changing the Error Delimiters

By default, the Form Validation class adds a paragraph tag (<p>) around each error message shown. You can either change these delimiters globally or individually.
1.Changing delimiters Globally
To globally change the error delimiters, in your controller function, just after loading the Form Validation class, add this:
$this->form_validation->set_error_delimiters('<div class="error">', '</div>');
In this example, we've switched to using div tags.

2.Changing delimiters Individually
Each of the two error generating functions shown in this tutorial can be supplied their own delimiters as follows:
&lt;?php echo form_error('field name', '<div class="error">', '</div>'); ?&gt;
Or:
&lt;?php echo validation_errors('<div class="error">', '</div>'); ?&gt;

InsiteFX