JSFiddle - React, Tailwind, and code Playground
HTML
<form name="form1" id="form1">
<div>
<label>Quantidade:</label>
<input type="text" name="qtd1" id="qtd1" onBlur="chama_onChange()" value="0">
</div>
<div>
<label>Preco:</label>
<input type="text" name="pc1" id="pc1" onBlur="chama_onChange()" value="0">
</div>
<div>
<label>Total:</label>
<input type="text" name="total1" id="total1" disabled>
</div>
</form>
CSS
label {
display:table;
}
JavaScript
function chama_onChange()
{
var qtd1 = document.getElementById("qtd1");
var pc1 = document.getElementById("pc1");
var total1 = document.getElementById("total1");
if (isNumber(qtd1.value) && isNumber(pc1.value))
{
total1.value = parseFloat(qtd1.value) * parseFloat(pc1.value);
}
else
{
total1.value = 0;
}
}
function isNumber(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}