It is possible to format values in the text field of a form while typing, for example, using a mile separator, e.g.:
function formatarMoeda(numero) {
return numero.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
}
console.log(formatarMoeda(2000)); // 2.000
console.log(formatarMoeda(200000)); // 200.000
console.log(formatarMoeda(1000000)); // 1.000.000
console.log(formatarMoeda(100)); // 100