Mask for monetary values

4

I wanted to create a mask for monetary values, where the person would enter and enter the scores and separations of the decimal places automatically. Ex:

  

$ 1

     

R $, 11

     

$ 1.10

     

$ 11.00

     

$ 110.00

     

$ 1,110.00

and so on

I tried using jQuery.InputMask from NuGet, but it only serves to use a full mask

    
asked by anonymous 11.11.2016 / 18:10

1 answer

7

There are several plugins ( list of jQuery mask plugins ). For your requirements jquery-maskMoney seems to be ideal:

$("#meuDinheiro").maskMoney();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/jquery-maskmoney/3.0.2/jquery.maskMoney.min.js"></script>



<input type="text" id="meuDinheiro" data-thousands="." data-decimal="," data-prefix="R$ " />
    
11.11.2016 / 18:17