Guest User

Untitled

a guest
Dec 13th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. function calcular2() {
  2. var txtValor = 'R$ 15,00'; //document.getElementById("txtValoraPagar").value;
  3. var txtDesconto = 'R$ 5,00'; //document.getElementById("txtDesconto").value;
  4. var txtTotalPagar = 0; //document.getElementById("txtTotalPagar");
  5. var valor =0;
  6. var desconto =0;
  7. if(txtValor != null)
  8. valor = Number(txtValor.replace(/[R$ ]/g, '').replace(',', '.'));
  9. if(txtDesconto != null)
  10. desconto = Number(txtDesconto.replace(/[R$ ]/g, '').replace(',', '.'));
  11. if(desconto > valor){
  12. alert('Valor do desconto não pode ser maior do que o valor a receber.');
  13. return false;
  14. } else if (valor >= desconto){
  15. txtTotalPagar = valor - desconto;
  16. console.log(txtTotalPagar);
  17. }
  18. }
Add Comment
Please, Sign In to add comment