function numMoedaDecimal(event,campo){ teclas(campo); str = campo.value; while(str.search(",") != -1) str = str.replace(",",""); i = 0; part1 = str.substr(0,str.length - 2); while(part1.search(" ") != -1) part1 = part1.replace(" ",""); part2 = str.substr(str.length - 2,2); res = ""; i = part1.length; sob = i % 3; if((sob != 0) && (i > 2)) res = part1.substr(0,sob); else res = part1.substr(0,sob); j = 1; part1 = part1.substr(sob); i = 0; while(i < part1.length){ if(j == 3){ if(i + 1 == part1.length) res = res + part1.substr(i-2,3); else res = res + part1.substr(i-2,3); } i++; j = j<3?j+1:1; } campo.value = res + "," + part2; }