Format monetary fields

0

I have a field that contains a mask:

ButIneedittocomeback,soitlookslikethis:

1212.12

Itriedthecodebelow,butitdidnotwork:

HTML

<inputtype="text" name="Valor" id="valor">

JQuery

var nValor = $("#valor").val().split('R$');
var novo = nValor[1].formatMoney(2, '.', ',');
    
asked by anonymous 01.07.2017 / 18:28

1 answer

0

I was able to resolve it as follows:

var valor = "R$ 11.000,00";
var nValor = valor.val().split('R$');
moedaFloat(nValor);
function moedaFloat(valor){
         moeda = moeda.replace(".","");
         moeda = moeda.replace(",",".");
         return parseFloat(moeda);
   }
    
01.07.2017 / 19:19