Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function calcular2() {
- var txtValor = 'R$ 15,00'; //document.getElementById("txtValoraPagar").value;
- var txtDesconto = 'R$ 5,00'; //document.getElementById("txtDesconto").value;
- var txtTotalPagar = 0; //document.getElementById("txtTotalPagar");
- var valor =0;
- var desconto =0;
- if(txtValor != null)
- valor = Number(txtValor.replace(/[R$ ]/g, '').replace(',', '.'));
- if(txtDesconto != null)
- desconto = Number(txtDesconto.replace(/[R$ ]/g, '').replace(',', '.'));
- if(desconto > valor){
- alert('Valor do desconto não pode ser maior do que o valor a receber.');
- return false;
- } else if (valor >= desconto){
- txtTotalPagar = valor - desconto;
- console.log(txtTotalPagar);
- }
- }
Add Comment
Please, Sign In to add comment