![]() |
acceptable when using javascript? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: acceptable when using javascript? (/showthread.php?tid=31154) |
acceptable when using javascript? - El Forum - 06-08-2010 [eluser]dottedquad[/eluser] Hello all, When is it acceptable to use javascript and when it is not acceptable? For example I created a form and perform the first set of validation on client side. When client-side validates javascript then sends the form values via AJAX/JSON to the server-side, but I haven't gotten that for yet. I'm hoping to fulfill this need using Codeigniter. -Rich acceptable when using javascript? - El Forum - 06-08-2010 [eluser]nelson.wells[/eluser] Why would that not be acceptable? Javascript validation on the client side can be used to 1) reduce multiple requests to the server and 2) enhance usability. As long as it degrades gracefully and you have server side validation as well, there is really no reason not to use javascript in a case like this. acceptable when using javascript? - El Forum - 06-08-2010 [eluser]dottedquad[/eluser] [quote author="nelson.wells" date="1276050084"]Why would that not be acceptable? Javascript validation on the client side can be used to 1) reduce multiple requests to the server and 2) enhance usability. As long as it degrades gracefully and you have server side validation as well, there is really no reason not to use javascript in a case like this.[/quote] I thought the same as well, but coding double the amount of work also crossed my mind. I didn't want to waist my time. -Rich acceptable when using javascript? - El Forum - 06-09-2010 [eluser]Flemming[/eluser] double coding - unfortunately it's the way! After trying lots of different approaches, I've eventually settled on this (using jquery validate): immediately after my CI validation rules, I write the same jquery validate rules like this... Code: $this->form_validation->set_rules('headline', 'Headline', 'trim|required|max_length[250]|xss_clean'); then in my view, indside the <head> I check to see if there's any jquery validation to write: Code: <?php this needs the jquery and the validation plugin but I find it cuts down a fair bit of work and repetition. If anyone has any slicker way I'd love to hear them! |