4

Maybe I'm just being lazy though.

Maybe I'm just being lazy though.

14 comments

[–] xyzzy 1 points (+1|-0)

A trim() is usually a good thing when handling user input. I spent too many hours of my life fixing problems caused by not using it.

Programmer Pro-tip #127: Language depending, Trim() has a parameter override allowing you to trim more than just spaces.

Javascript doesn't have this but you can easily write a method to replace the default trim method so that you can do this.

[–] xyzzy 1 points (+1|-0)

In my worst situation a .trim would haven trimmed all whitespace, but it wasn't used since there was a character limit. Too bad users copied from emails including a few dozen newlines at the end.

Wasn't hard to fix, but hard to find.