ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Codeigniter and Jquery Validation Plugin

August 01, 2011 4:42pm

Subscribe [0]
  • #1 / Aug 01, 2011 4:42pm

    parkej60

    2 posts

    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');
            }
        }
  • #2 / Aug 01, 2011 5:44pm

    parkej60

    2 posts

    I’m dumb this had nothing to do with CI. I had 2 ids in my HTML named the same thing.

  • #3 / Aug 25, 2011 2:22pm

    wahyu24

    7 posts

    thanks nice share :D

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases