/*手机代码格式化一般与Object.oninput=function(){}连用*/
function phoneFormat(phone){ if(phone.length <= 3 ){ return phone; } return phone.slice(0,3) + (phone.slice(3) == "" ? "":(" " + phoneFormatMethd(phone.slice(3)))); } function phoneFormatMethd(phone4){ return phone4.slice(0,4) + (phone4.slice(4) == "" ? "":(" " + phoneFormatMethd(phone4.slice(4)))); }
/*去除字符串所有空格*/ function globalTrim(str,is_global){ var result; result = str.replace(/(^\s+)|(\s+$)/g,""); if(is_global.toLowerCase()=="g"){ result = result.replace(/\s/g,""); } return result; }