OnChange function in Javascript, only works with TAB in Bootstrap

0

Good evening.

I have a bootstrap form with modal that when entering the values, the calculation is only done after giving a TAB to change the field.

But by doing the test here, it works with TAB and clicking with the mouse in another field. I do not understand why Bootstrap with Modal only works with TAB.

Do you know how I can fix this?

$("#percentualDesconto").change(function () {
                    var valor = $("#valor_compra").val();
                    var valorDesconto = valor * (parseFloat($(this).val()) / 100);
                    var valorArrendodado = parseFloat(valorDesconto.toFixed(2));
                    $(".desconto").val(valorArrendodado);
                    var Valor1 = parseFloat($('.desconto').val());
                    var Valor1Arrendodado = parseFloat(Valor1.toFixed(2));

                    var resultadoFinal = valor - Valor1Arrendodado;
                    if (Number.isNaN(resultadoFinal)) {
                        TotFR = 0;
                        $('#valor_desconto').val(resultadoFinal.toFixed(2));
                    } else {
                        $('#valor_desconto').val(resultadoFinal.toFixed(2));
                    }
                });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script><divclass="row">                                        
                                        <div class="form-group col-md-3">
                                            <label for="valor_compra">Valor Compra</label>                                 
                                            <input type="text" class="form-control" id="valor_compra" name="valor" value="0.00"  >
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label for="percentualDesconto">Desconto(%)</label>                                
                                            <input type="text" class="form-control " name="percentualDesconto" value="0.00" id="percentualDesconto" title="Informe o percentual"  size="15" maxlength="25" placeholder="0.00 %"  >
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label for="desconto">Desconto</label>                                 
                                            <input type="text" class="form-control desconto" id="desconto" name="desconto" value="0.00" readonly >
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label for="valor_desconto">Valor Final </label>                                 
                                            <input type="text" class="form-control" id="valor_desconto" name="valorComDesconto" value="0.00" readonly >
                                        </div>
                                    </div>
    
asked by anonymous 05.01.2017 / 23:08

1 answer

0

Good evening, excuse me, I removed the maskMoney library: link

And now it works, I'll just study a solution to prevent the user from putting "comma" instead of "dot".

    
05.01.2017 / 23:19