Creating masks for coins with JQuery

Criando Máscaras para moedas com JQuery
Creating masks for coins with JQuery

This plugin was developed based on the original “Masked Input Plugin“. With this plugin it is super easy to create masks for coins.

How to use:

First you need to call the jquery.min.js and jquery.maskMoney.js files

<script src="jquery.min.js" type="text/javascript"></script>
<script src="jquery.maskMoney.js" type="text/javascript"></script>

Then you enter the code that formats the fields

 <script type="text/javascript">

 Remember that the #value must match the field id, eg:

For formatting in R$, use the following script

<script type="text/javascript">
 $("#demo4").maskMoney({symbol:'R$ ', 
showSymbol:true, thousands:'.', decimal:',', symbolStay: true});

Visit the Plugin website MaskMoney

See some examples of masks

See also some values of the default maskMoney configuration

  • symbol: the symbol to be used before the user values. default: 'USA $'
  • showSymbol: set whether the symbol should be displayed or not. default: false
  • symbolStay: define whether the symbol will stay in the field after the user exists in the field. default: false
  • thousands: the thousands separator. standard: ','
  • decimal: the decimal separator. standard: '.'
  • precision: how many decimal places are allowed. default: 2
  • defaultZero: when the user enters the field, he sets a default mask using zero. default: true
  • allowZero: use this setting to prevent users from entering with zero. default: false
  • allowNegative: use this setting to prevent users from entering negative values. default: false
{ symbol:'US$', // Decimal symbol:'.', // Decimal separator precision:2, // Precision thousands:',', // Separator for thousands allowZero:false, // Allow digit 0 be the first character showSymbol:false // show/hide symbol }

 2,928 Total Visualizações,  4 Visualizações Hoje


  1. I followed the steps and it worked, however, this script conflicted with a date that I use Datepicker, it stopped working. The script that is declared after it works. Do you know the reason?

    $(function() {
    $.datepicker.setDefaults( $.datepicker.regional[ “” ] );
    $( “#datepicker” ).datepicker( $.datepicker.regional[ “pt-BR” ] );

    $(“#value”).maskMoney({symbol:'R$ ', showSymbol:true, thousands:'.', decimal:',', symbolStay: true});

    1. Hello Cassia,
      Probably some conflict between roles.
      Tried to reverse the order to see if it works? Also see how many jQuery are being requested (sometimes the other script also asks for a jQuery getting duplicated).

  2. Is it possible to apply the mask directly on the variable? and not in the input field? I want to dynamically print values in the field and I want it to be filled with the mask. How do I do?

  3. When I apply the mask on the 9-digit phone, it looks like this (99)9999-99999. How do I look like this: (99) 99999-9999? with 5 digits before – and 4 after.

  4. Forgiveness. disregard my comment I just made.
    I have two tabs open, one about phone masks and one about coin masks.
    I switched pages when submitting the question.
    Pardon me!
    And taking advantage, I used your coin mask. It worked just fine! Congratulations!

  5. Thank you very much, it worked perfectly.

    For those who use more than two jQuery libraries, or more than one version and are having a conflict,
    use noConflict(); That's how I did it, and everything worked out ;D

  6. Fábio, congratulations for the post, but I had a question. The field that will receive this information in mysql must have what Type?
    I would like to search for these values and carry out operations.

  7. Buddy, I would like to thank you so much! I'm in college, and this site is helping me a lot!

    Thank you very much!!

  8. Thanks for the tip! Your collaboration is very important to all of us Internet users on duty.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.