• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Form Validation through JQUERY

I have a couple of questions:
What is best practice, use CodeIgniters Validation Class for form validation or use something like http://plugins.jquery.com/project/RSV ?

Also, is it possible to use CodeIgniters Validation Class in an AJAX kind of way?

For now, I've been using CodeIgniters Validation Class in my small application,
but I want instant validation when a user enters values in a form instead of having to submit the form first.

Any help would be greatly appreciated.

Oh, and might I add that CodeIgniter is just amazing!
Never used any other php-framework before because they all seemed so bloated and difficult to learn, but CodeIgniter is really easy to learn and has helped me improve my programming a lot!

Best practice is to validate on both Client and Server.

Validate on Client because it helps the user interface. JQuery will help with things like checking fields as the user types (or after submission of form) rather than after the form is submitted to the server and the page refreshed.

However, if (say) the user chooses to disable JavaScript, or the JavaScript code dies in the browser, then your server is wide open to receive unverified and unvalidated input.

I fully agree with Crafter. Add the jQuery validation for the comfort of your users, keep the CI validation for your own good.

And no, the CI validation can't be ajaxified, seeing as Ajax is based on Javascript, which is client side and the CI validation methods are php, which are server side...

It would be possible to write a library/js files that would setup client side validation according to the rules you set in the validation class, but that would require client side scripting from CI, which isn't part of CI at all. And if the library were to use a javascript framework, things would get even more complicated, seeing as not everyone uses jQuery or Prototype or Mootools or whatever.

thank you so much for the clear answers Smile

I was aware of the need to keep the server side validation.
To think of it, my question to ajaxify the validation class was a bit dumb.

It's just that of course the standard rules in the CI validation class are not necessarily the same as those in the jquery validation which would mean extra coding of course. (extending the CI validation class?)

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.