ScriptAdhesionValue
functionmascara(o,f){v_obj=ov_fun=fsetTimeout("execmascara()",1)
}
function execmascara(){
v_obj.value=v_fun(v_obj.value)
}
function mreais(v){
v=v.replace(/\D/g,"") //Remove tudo o que não é dígito
v=v.replace(/(\d{2})$/,",$1") //Coloca a virgula
v=v.replace(/(\d+)(\d{3},\d{2})$/g,"$1.$2") //Coloca o primeiro ponto
return v
}
Adhesion Value Input:
<input type="text" id="txt1" name="adesao" class="form-control calcular" placeholder="R$" onkeypress="mascara(this,mreais)" onkeyup="calcular()">
Total Value Script
function calcular() {
var soma = $('.calcular').get().reduce(function(soma, el) {
return (parseFloat(el.value.replace(/\./g, "").replace(",", "."), 10) || 0) + soma;
}, 0);
document.getElementById('result').value = soma;
}
Total Value Input
<input type="text" class="form-control" name="total" id="result" readonly>