Welcome Guest, Not a member yet? Register   Sign In
Custom validation function doesn't work.
#1

[eluser]loathsome[/eluser]
Hello,

I've tried this numerous times now, and I can never get the validation class to accept my custom rules. Take this example.

Code:
<?php

class Welcome extends Controller {
    
    function __construct()
    {
        parent::Controller();
    }
    
    function index()
    {
        $this->load->helper('form');
        $this->load->library('validation');
        
        $rules['name'] = 'mekk';
        $fields['name'] = 'username';
        
        $this->validation->set_rules($rules);
        $this->validation->set_fields($fields);
        
        if(FALSE == $this->validation->run())
        {
            $this->load->view('theform');
        }
        /**
         * the form won
         **/
        else
        {
            $this->load->view('success');
        }
    }
    
    /**
     * callback functions
     **/
    
    function mekk($input)
    {
        if($input == 'hello')
        {
            return true;
        }
        else return false;
    }
    
}

No matter what I type into the field, it goes through. I want it ONLY to validate if I write "hello".

Appreciate any help. Thanks a lot!


Messages In This Thread
Custom validation function doesn't work. - by El Forum - 09-25-2008, 02:08 AM
Custom validation function doesn't work. - by El Forum - 09-25-2008, 02:18 AM
Custom validation function doesn't work. - by El Forum - 09-25-2008, 02:21 AM
Custom validation function doesn't work. - by El Forum - 09-25-2008, 02:26 AM
Custom validation function doesn't work. - by El Forum - 09-25-2008, 02:29 AM



Theme © iAndrew 2016 - Forum software by © MyBB