Welcome Guest, Not a member yet? Register   Sign In
triming on data submitting
#1

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!
Reply
#2

Try with jQuery to stop every whitespace Smile
Reply
#3

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);
http://php.net/manual/en/function.trim.php

Jquery's trim function
Code:
$.trim(string);
https://api.jquery.com/jQuery.trim/

Javascript trim function
Code:
string.trim()
http://www.w3schools.com/jsref/jsref_trim_string.asp

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
Reply




Theme © iAndrew 2016 - Forum software by © MyBB