$this->load->library("form_validation"); $this->form_validation->set_rules("username", "User name", "trim|required"); if($this->form_validation->run() === FALSE) { //$this->view_data["errors"] = validation_errors(); } else { //codes to run on success validation here }