Use Maskmoney this way:
Press jQuery and Maskmoney on the page:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-maskmoney/3.0.2/jquery.maskMoney.min.js"></script>
Add the class .mascara
to inputs
that you want to create the mask:
<input type="text" class="mascara" />
Launch 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>
<script src="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" >
'.maskMoney()' only works with the specific library, as Sam reported in another reply.
– Jhonny Mesquita