function trim(x) { return x = (x != null) ? x.replace(/^[\t\n\r\s]*|[\t\n\r\s]*$/g,"") : false ; }
Tuesday, August 18, 2009
Better JavaScript Trim
I'm continuing the trend of posting updated code with the new version of the trim function for JavaScript. JS doesn't include a trim() function by default so you have to build one yourself. Below is the snippet that I use to accomplish the task:
Subscribe to:
Post Comments (Atom)


0 comments:
Post a Comment