I’m having trouble getting forms on my site to recognize the jquery validation script. The scripts all load successfully, but when I click on submit it just gives me the CI validation errors and doesn’t seem to stop on the validate() function.
I’m not doing anything complicated. Just redirecting on form submit to a function in my controller that does validation, redirects if successful and reloads the view with errors if it’s not. Like I said before it just seems as if the Jquery validation plugin is not catching the errors like it normally does.
Example of my controller function.
public function login($redirect = '')
{
//Load codeigniters validation library and set rules
$this->load->library('form_validation');
$this->form_validation->set_rules('email','Email Address','required|valid_email');
$this->form_validation->set_rules('password','Password','required|min_length[4]');
$login_error['success'] = true;
$login_error['value'] = '';
//If our validation runs succesfully test the user info
if($this->form_validation->run() !== false){
$this->load->model('userModel');
//Check DB For user info
$user = $this
->userModel
->verify_user(
$this->input->post('email'),
$this->input->post('password')
);
$this->processUser($user,$redirect);
}else{
$this->load->model('sitesmodel');
$login_error['success'] = false;
$this->load->view($this->controller.'/header',array('page'=>'login'));
$this->load->view($this->controller."/login",array('login_error'=>$login_error,
'redirect'=> $redirect,
'questions'=>$this->userSpecificQuestions(),
'order_options'=>$this->getOrderOptions(),
'specials'=>$this->sitesmodel->getAllSiteLists($this->site->id)
)
);
$this->load->view($this->controller.'/footer');
}
}