Reputation: 139
Guys I am stuck here in Codeigniter validation. The scenario is that I want to display all the error messages right below each respective input field and not all the error messages together on the top of the form. Could anyone help me, how to do this?
Upvotes: 0
Views: 59
Reputation: 112
write below code after your text or drop-down field
<?php echo form_error('field_name','<div class="errorClass">','</div>');?>
Upvotes: 0
Reputation: 2993
Check below mentioned code. This will help you.
<h5>Username</h5>
<?php echo form_error('username'); ?>
<input type="text" name="username" value="<?php echo set_value('username'); ?>" size="50" />
<h5>Password</h5>
<?php echo form_error('password'); ?>
<input type="text" name="password" value="<?php echo set_value('password'); ?>" size="50" />
<h5>Password Confirm</h5>
<?php echo form_error('passconf'); ?>
<input type="text" name="passconf" value="<?php echo set_value('passconf'); ?>" size="50" />
<h5>Email Address</h5>
<?php echo form_error('email'); ?>
<input type="text" name="email" value="<?php echo set_value('email'); ?>" size="50" />
Upvotes: 1
Reputation: 5398
Use form_error()
function to do that. As describe in manual
echo form_error('username');
All you have to do is put this line under the field where you want to see error message. Here username
is the name of the form field
more details https://www.codeigniter.com/user_guide/libraries/form_validation.html#showing-errors-individually
Upvotes: 1