How to create a mask for values in Reais R $? I tried using link but I did not succeed.
I'm in need of a mask to present me with something like this: R $ 0.01 R $ 0.10 R $ 1,00 R $ 10.00 R $ 100.00 R $ 1,000.00 Something like this !!!
How to create a mask for values in Reais R $? I tried using link but I did not succeed.
I'm in need of a mask to present me with something like this: R $ 0.01 R $ 0.10 R $ 1,00 R $ 10.00 R $ 100.00 R $ 1,000.00 Something like this !!!
Try using the code below:
$("#demo3").maskMoney({prefix:'R$ ', allowNegative: true, thousands:'.', decimal:',', affixesStay: false});
Use MaskMoney this way:
Load jQuery and MaskMoney on the page:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/jquery-maskmoney/3.0.2/jquery.maskMoney.min.js"></script>
Add the class .mascara
to the inputs
you want to create the mask:
<input type="text" class="mascara" />
Start the plugin:
<script>
$(function(){
$(".mascara").maskMoney({
prefix: 'R$ ',
allowNegative: true,
thousands: '.',
decimal: ','
});
});
</script>
Example:
$(function(){
$(".mascara").maskMoney({
prefix: 'R$ ',
allowNegative: true,
thousands: '.',
decimal: ','
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/jquery-maskmoney/3.0.2/jquery.maskMoney.min.js"></script>
<input name="valor1" type="text" class="mascara" >
<br />
<input name="valor2" type="text" class="mascara" >