[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!