codeigniter form validation example
Example 1: codeigniter form_validation email
$this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email');
Example 2: codeigniter load form_validation
<?php
class Form extends CI_Controller {
public function index()
{
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('myform');
}
else
{
$this->load->view('formsuccess');
}
}
}
Example 3: codeigniter validation text length
$this->form_validation->set_rules('ratingMessage', 'Review message', 'trim|max_length[255]|max_length[10]');
$this->form_validation->set_message('max_length', 'Message you have entered for %s is too long please try again!');