I'm trying to replicate a calculator from my Excel spreadsheet to a webpage. The first field is an input to natural numbers (without commas), the second is to some currency values (with commas, points, etc) and the third is the total, but it has a defined value (for example, 0,38 cents). Both of the fields must multiply and give a result in the third field.
I tried to create a mask using a mask plugin, but had several errors. Tried to use toLocaleStrings too.
I'm having problems with the masks and the results.
That's the expected result :

HTML
<form>
<!-- simple number to start the calculation -->
<label>Natural Number</label>
<input type="text" id="base" />
<br>
<!-- currency including the cents -->
<label>Currency value</label>
<input type="text" id="ticket" />
<br>
<!-- If the first field is "1" and the second is "1,00", this field has a value of 0.38 cents. -->
<label>Currency total</label>
<input type="text" id="cost" readonly /></form>
JQUERY
$(document).ready(function(){
$('#cost').mask('000.000.000.000.000,00', {reverse: true});
$('#base').keyup(calculate);
$('#ticket').keyup(calculate)
function calculate(e) {
$('#cost').val($('#base').val() * $('#ticket').val() * 0.38).trigger('input')
}
});