Welcome Guest, Not a member yet? Register   Sign In
Client+Server-side validation

Here's my first attempt at implementing automatic generation of the javascript code for client-side validation using CI standard validation rules:

1. Somewhere in your controller, add a method defining your validation rules:
function setup_validation()

2. Call this method when displaying web form. The client-side validation javascript will be automatically created for you.
$data['javascript'] = $this->validation->javascript();
$this->load->view('view', $data);

3. Call the exact same method again when processing submitted form data on the server side, as usual:
if ($this->validation->run() == true)
    ... etc.

To install, place MY_Validation.php class in application/libraries folder.

For more info, see CI Wiki

Can you please provide download for MY_Validation.php ? GitHub escaped/striped some tags and its pain in the ass to figure out what is what and return it the way it was...(even with find and replace)
For example most of the < tags have been replaced with
& l t ;

Will CI load jQuery.validation.js automaticly when its needed or....(didnt see it in a code and didnt read that we need to include it)

And what about custom error messages on a client side?
$this->form_validation->set_message('rule', 'Error Message');
We use it like that?

Nice work!

Theme © iAndrew 2016 - Forum software by © MyBB