Welcome Guest, Not a member yet? Register   Sign In
How to implement JS validations through CodeIgniter
#8

[eluser]xwero[/eluser]
Code:
/*-------------------------------------------------------
view_validate.php // inside view folder
-------------------------------------------------------*/
echo form_open("JsValidation/form");
echo $this->validation->error_string;
$data = array(
              'name'        => 'txtFullName',
              'id'          => 'txtFullName',
              'value'       => '',
              'maxlength'   => '100',
              'size'        => '50',
              'style'       => 'width:50%',
            );

echo form_input($data);
echo form_submit('mysubmit', 'Submit Post!');


/*-------------------------------------------------------
And here is my controller code
-------------------------------------------------------*/
class JsValidation extends Controller
{
    function JsValidation()
    {
        parent::Controller();    
        $this->load->helper("form");
        $this->load->helper("url"); // for the redirect function
        $this->load->library('validation');
        
    }

    function form()
    {
        if(count($_POST) > 0)
        {
           $rules['txtFullName'] = 'required';
           $this->validation->set_rules($rules);
           $fields['txtFullName'] = 'full name';
           $this->validation->set_fields($fields);
           if($this->validation->run() === TRUE)
           {
               redirect('JsValidation/success');
           }
        }
        $this->load->view("view_validate");
    }
    function success()
    {
        $this->load->view("view_success");
    }
}
For more examples and possibilities check the user guide.


Messages In This Thread
How to implement JS validations through CodeIgniter - by El Forum - 03-03-2008, 05:19 AM
How to implement JS validations through CodeIgniter - by El Forum - 03-03-2008, 05:29 AM
How to implement JS validations through CodeIgniter - by El Forum - 03-03-2008, 05:32 AM
How to implement JS validations through CodeIgniter - by El Forum - 03-03-2008, 05:52 AM
How to implement JS validations through CodeIgniter - by El Forum - 03-04-2008, 02:30 AM
How to implement JS validations through CodeIgniter - by El Forum - 03-04-2008, 02:40 AM
How to implement JS validations through CodeIgniter - by El Forum - 03-04-2008, 04:23 AM
How to implement JS validations through CodeIgniter - by El Forum - 03-04-2008, 04:33 AM



Theme © iAndrew 2016 - Forum software by © MyBB