Do form validation with jquery ajax in codeigniter
<p>How can i do form validation in codeigniter if i don't want to refresh the page?
Basically i do this:</p>

<pre><code>    $config = array(
            array(
                    'field' =&gt; 'c_name',
                    'label' =&gt; 'Name',
                    'rules' =&gt; 'trim|required'
            ),
            array(
                    'field' =&gt; 'c_job',
                    'label' =&gt; 'Job',
                    'rules' =&gt; 'trim|required',
                    )
    );
    $this-&gt;form_validation-&gt;set_rules($config);
    if($this-&gt;form_validation-&gt;run() == true)
            {
                $this-&gt;load-&gt;model('model');
                //.....
            }
    else{
            $this-&gt;load-&gt;view('view');
        }
</code></pre>

<p>But if i send data with ajax and the page doesn't refresh, How can i do form validation?</p>

<p>Edit:</p>

<p>Thanks @ Amra Kojon. That's good and works but the new problem is this:</p>

<pre><code>if ($this-&gt;form_validation-&gt;run() == FALSE) {
                echo validation_errors();
                } 
                else {
                        //echo 'hi';


                        $value = $this-&gt;input-&gt;post('value');

                        $values = array(
                                'c_name' =&gt; $value['c_name'],
                                'c_job'=&gt; $value['c_job'],
                                'c_address'=&gt; $value['c_address'],
                                'c_phone'=&gt; $value['c_phone'],
                                'c_mail'=&gt; $value['c_mail'],
                                'c_state'=&gt; $value['c_state'],
                                'c_intrest'=&gt; $value['c_intrest'],
                                'c_added_info'=&gt; $value['c_added_info']
                        );


                        $add = $this-&gt;customers_model-&gt;add_customer($values);
                        echo $add;
                }  
</code></pre>

<p>If i just say echo "something" in the else part, It works and if the validation were OK, It echo hi but if i write theme in database (Which the value array has data and in not ajax way, it insert date), It doesn't work and the else part isn't working!!! </p>