//载入验证类
$this->load->library('form_validation');
//验证是否有输入用户名
$this->form_validation->set_rules('username', 'username', 'required');
//启动验证
$this->load->library('form_validation');
//验证是否有输入用户名
$this->form_validation->set_rules('username', 'username', 'required');
//验证是否有输入密码
$this->form_validation->set_rules('password', 'password', 'required');//启动验证
$status=$this->form_validation->run();
官方手册介绍 : http://codeigniter.org.cn/user_guide/libraries/form_validation.html