javascript trim space removal function implementation code
http://www.jb51.net/article/16250.htm
The following is the enhanced version
// Function: 1) Remove all spaces before and after the string
// 2) Remove characters All spaces in the string (including spaces in the middle, you need to set the second parameter to: g)
function Trim(str,is_global)
{
var result;
result = str.replace(/( ^s )|(s $)/g,"");
if(is_global.toLowerCase()=="g")
result = result.replace(/s/g,"");
return result;
}