How do I make my input stay with the decimal places ....
I need it to format in #total_compra
follow code
<script type="text/javascript">
$(document).ready(function() {
$("#evento_quantidade").change(function() {
var qtd = $(this).val();
var valor = $("#precoSoma").val();
var calculo = qtd * valor;
$("#total_compra").val(calculo);
});
String.prototype.formatMoney = function() {
var v = this;
if(v.indexOf('.') === -1) {
v = v.replace(/([\d]+)/, "$1,00");
}
v = v.replace(/([\d]+)\.([\d]{1})$/, "$1,$20");
v = v.replace(/([\d]+)\.([\d]{2})$/, "$1,$2");
v = v.replace(/([\d]+)([\d]{3}),([\d]{2})$/, "$1.$2,$3");
return v;
};
});
</script>