jQuery Tidbits : jQuery.trim()

Pesky users.  Sometimes when they type in stuff they’ll throw in an extra space at the beginning or end of the input.  Usually we can just take care of that stuff on the server, but why should we waste the precious resources of the server by trimming a string?  Let the client take care of it.

jQuery includes a nice helper method that’ll do this for you.  Check out the following example:

var badString = “    Oh look at this!  Kevin needs to trim his strings.   “;  
badString = $.trim(badString);

Check out more here!

comments powered by Disqus