0
I would like to know how I can be putting coin mask, since my input="Resulted field" is locked and added value automatically after placing a value in the above input.
I tried to add the mask in the input itself="Resulted field", but without success.
Thank you!
<!DOCTYPE html>
<html lang="pt-br">
<head>
<title>Título da página</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link href="https://fonts.googleapis.com/css?family=Titillium+Web" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.11/jquery.mask.min.js"></script>
<script>
function troca(valor){
var campo1 = document.getElementById("ncorridas").value;
var resultado = parseFloat(campo1);
resultado = resultado*5400;
document.getElementById('campoResultado').value = ('R$ ') + resultado + (' reais por ano!');
}
</script>
<b>Número de corridas por dia <input class="w3-input w3-border" type="number" name="ncorridas" id="ncorridas" min="0" onChange="troca(this.value)" />
</head>
<body>
Valor:<input readonly="true" class="w3-input w3-border" type="text" name="campoResultado" id="campoResultado" /></b>
</body>
</html>