function dealSumMoney(money_num){ var num = money_num.split('.')[0]; var length = num.length; var group = length/3 + 1; var result = ""; for(var i=0 ; i< group ; i++){ if((length-3*(i+1))<=0){ result = num.substring(0,length-3*i)+result; }else{ result=","+num.substring((length-3*(i+1)),(length-3*i))+result; } } if(money_num.split('.')[1] != null ){ return result+ "." + money_num.split('.')[1]; } return result ;}alert(dealSumMoney("50000"));alert(dealSumMoney("50000.00"));