triming on data submitting |
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!
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/l...pping-data |
Welcome Guest, Not a member yet? Register Sign In |