function trim(str){ if(str!=''&&typeof str!='undefined'){ return str.replace(/(^\s*)|(\s*$)/g, ""); }else{ return str; } }