Adding new validation - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Adding new validation (/showthread.php?tid=80280) |
Adding new validation - Knutsford - 10-11-2021 How do I add a new form validation? I have PHP Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); Code: But it is causing a Javascript error Code: array( Code: 'field' => 'order_first_name', Code: 'label' => 'First name', Code: 'rules' => 'trim|required|alpha_space' Code: ), Code: array( Code: 'field' => 'order_last_name', Code: 'label' => 'Last name', Code: 'rules' => 'trim|required|alpha_space' Code: ), RE: Adding new validation - Knutsford - 10-12-2021 (10-11-2021, 11:05 AM)Knutsford Wrote: How do I add a new form validation? It is Codeigniter 2 if that helps RE: Adding new validation - InsiteFX - 10-12-2021 Upgrade to 4, CodeIgniter 2 has security issues. RE: Adding new validation - Knutsford - 10-12-2021 Upgrading to 4 is on the cards sometime What I posted is what I tried and I was getting a JavaScript error - something to do with the order id which didn't make sense at all as it isn't part of the form. I am wondering if I should try callback instead RE: Adding new validation - includebeer - 10-12-2021 Maybe this has nothing to do with your problem, but “&” is a bitwise operator. You should use “&&” instead. https://www.php.net/manual/en/language.operators.bitwise.php https://www.php.net/manual/en/language.operators.logical.php RE: Adding new validation - Knutsford - 10-13-2021 Yep you are right I have always had a problem with & and && for some reason. I tried doing the validation using callback last night but couldn't get it to work RE: Adding new validation - includebeer - 10-13-2021 I you don’t want to upgrade to CI4 at the moment, you should at least upgrade to CI3. The steps from CI2 to CI3 are quick and easy and you would at least have documentation for that version. Because CI2 is very outdated and the user guide is no longer available. So it’s hard to tell what’s wrong with your code. RE: Adding new validation - Knutsford - 10-14-2021 Hmm some version upgrades are easy peasy but I don't remember going from 2 to 3 that easy when I have done it depending on how the site it has been written. Anyway I have got it working by being naughty and changing the core code which is what I aas trying to avoid. RE: Adding new validation - includebeer - 10-14-2021 Believe me, going from 3 to 4 is way more work than 2 to 3. |