Articles → PHP CODEIGNITER → Validation_Errors And Form_Error In Codeigniter
Validation_Errors And Form_Error In Codeigniter
Purpose
- "validation_errors" display the summary of all the error messages.
- "form_error" displays error messages at field level.
Example
$this->load->helper('form');
$this->load->library('form_validation');
$this->form_validation->set rules('username', 'Username', 'required');
$this->form_validation->set rules('name', 'Name', 'required');
$this->form_validation->run();
$this->load->view('users');
<?php
echo validation_errors();
echo form_open();
echo form_input('username', ");
echo form_error('username','');
echo form_input('name', '');
echo form_submit('mysubmit', 'Click Me');
echo form close();?>
Output
Click to Enlarge
Click to Enlarge