Calculate JS Value

0

I have a function for the total calculation.

$('.valor').blur(function(){
    var valor = $("input[name=valor]").val() || 0;
    var descontos = $("input[name=descontos]").val() || 0;
    var juros = $("input[name=juros]").val() || 0;

    valor_cobrado = (parseFloat(valor) - parseFloat(descontos)) + parseFloat(juros);
    $("#valor_cobrado").val(parseFloat(valor_cobrado));
});

The fields have comma currency masks but the total value is not taking into account the comma.

example 10.50 + 11.00 = 21.00

    
asked by anonymous 04.05.2018 / 17:25

1 answer

0

JS does not work with a comma, it has to change per point.

valor.replace(',', '.')

Then return to the video.

valor.replace('.', ',')
    
04.05.2018 / 18:04