Jump to content

trim rule doesn't work

trim validation rules

  • Please log in to reply
2 replies to this topic

#1 Jefer



  • Members
  • Pip
  • 6 posts

Posted 25 October 2013 - 05:40 PM

I am using trim function in a controller so login field can't contain whitespaces at the end but It doesn't work. The login is saved with white spaces.


here is the code.

        $crud = new grocery_CRUD();

what is wrong? or do I have to use a callback?

#2 edramirez


    Advanced Member

  • Members
  • PipPipPip
  • 63 posts
  • LocationMetro Manila

Posted 10 November 2013 - 02:14 PM

From my experience, grocerycrud's set_rules function doesn't operate exactly in the same way as codeigniter's counterpart. That being said, we have to accomplish our desired end in a different way. So, here's how I would do it.


Let's say that the login field is of type varchar(10). Make sure that the field is not of type char(10).


I would do it this way:



If the user forces to put any space, the validation rule kicks in.


Hope this helps.


Ed Ramirez


P.S. Don't forget to hit the like button!

#3 RMaynard



  • Members
  • Pip
  • 7 posts

Posted 23 November 2017 - 04:30 PM

I can't believe this is still an issue. The alpha_dash won't work for me, as I need to have spaces within the string, but not at the ends.

Also tagged with one or more of these keywords: trim, validation, rules

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users