Welcome Guest, Not a member yet? Register   Sign In
Twitter-like Registration with DX Auth
#4

[eluser]juliano.ma[/eluser]
Hello,

I am trying to implement this validation in real time on my form, but I must be missing something.

I have installed the JSON.

You could post an full example in the controller and view, please?

Code:
<?php
class Form extends Controller {
    
    function index()
    {
        $this->load->helper(array('form', 'url'));
        
        $this->load->library('validation');
        
        
        $rules['username'] = "callback_chk_username";
        
        $this->validation->set_rules($rules);

                
        if ($this->validation->run() == FALSE)
        {    
            $this->load->view('myform');
        }
        else
        {
            $this->load->view('formsuccess');
        }
    }


    
    function chk_username($name)
    {
        $b = true;
        $this->db->from('user');
        $this->db->where('username', $name);
        $query = $this->db->get();
        
        if($query->num_rows > 0)
        {
            $this->validation->set_message('chk_username', 'Not available');
            $b = false;
        }
        return $b;
    }


}
?>

Where i use this below, in controller or view?:

Code:
$json = array();
            $json['validation'] = validation_errors();
            echo json_enchode($json);


Look my view:

Code:
<?=$this->validation->error_string; ?>

<?=form_open('register');?>

<?
$dados = array(
              'class'       => 'username',
              'name'        => 'username',
              'id'          => 'username',
              'value'       => '',
              'size'        => '20',
            );

echo form_input($dados);
?>

<?

$dados_submit = array(
                    'type' => 'submit',
                    'name' => 'submit_user',
                    'value' => 'Send',
                    'id'   =>  'submit',
                    );
                    
echo form_submit($dados_submit);
?>


Messages In This Thread
Twitter-like Registration with DX Auth - by El Forum - 07-26-2009, 07:49 PM
Twitter-like Registration with DX Auth - by El Forum - 07-27-2009, 05:04 PM
Twitter-like Registration with DX Auth - by El Forum - 07-27-2009, 06:36 PM
Twitter-like Registration with DX Auth - by El Forum - 08-10-2009, 02:35 PM
Twitter-like Registration with DX Auth - by El Forum - 08-10-2009, 07:22 PM
Twitter-like Registration with DX Auth - by El Forum - 08-12-2009, 05:15 AM
Twitter-like Registration with DX Auth - by El Forum - 08-12-2009, 06:18 AM



Theme © iAndrew 2016 - Forum software by © MyBB