The CodeIgniter Form_Validation library is an extremely useful tool especially the ability to extend all core routines. Some validation requires real time PHP & MySQL processing, for example checking an email against those already registered with your site.

To use a PHP function to return values to the jQuery validate function, the only important theory to understand is that the function needs to echo, not return. Returning values will not send the output to the DOM and so the validation routines will not know what to do with it.

So here is an example of a function which uses a member model to check the email address against those already registered which will return boolean(true). The jQuery will post the information to this function.

function checkEmail() {
    $email = $this->input->post('email');

    if($this->members_model->checkDuplicate($email)) {
        echo 'true';
    } else {
        echo 'false';

To call this function we need to use the jQuery validate remote option.

    rules: {
        email: remote {
            url: "path/to/checkEmail",
            type: "post",
            data: {
                email: function() {
                    return $('#email').val();

This will provide real time PHP email validation which you can chose to fire on blur or on change or keyup. Your choice! Give it a go!