triming on data submitting - 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: triming on data submitting (/showthread.php?tid=67045) |
triming on data submitting - mstdmstd - 01-07-2017 Hi all, In CI 3.1 I can use trim condition if I want to make checks without trailing whitespaces PHP Code: $this->form_validation->set_rules('email', 'email', 'trim|required|valid_email'); But that is only for validating. If there are filters on data submitting/saving to remove whitespaces on enetered data, withoiut trim any field ? Thanks! RE: triming on data submitting - gaska96 - 01-07-2017 Try with jQuery to stop every whitespace RE: triming on data submitting - PaulD - 01-07-2017 You are always going to have to trim data to remove whitespace in text fields (if whitespace is a problem). Even if you do it with JS browser side, you will still have to check and remove it server side too. So you are always going to need a trim function of some sort. PHP's trim function, Code: trim($string); Jquery's trim function Code: $.trim(string); Javascript trim function Code: string.trim() The 'trim' in the form validation is just applying the native php's trim function. You can set any php function with just one argument to a validation check in CI. https://www.codeigniter.com/user_guide/libraries/form_validation.html#prepping-data |