消除输入的所有空格
function Trim(str,is_global) { var result = $.trim(str); result = str.replace(/(^\s+)|(\s+$)/g,""); if(is_global != undefined && is_global.toLowerCase()=="g") result = result.replace(/\s/g,""); return result; } var username=$('.name').val(); username=Trim(username);