Just a simple way to create masks to your currency form fields with jQuery. Forked to work with AngularJS
To view a complete demonstration of it's features and usage, access our examples page!
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js" type="text/javascript"></script>
<script src="jquery.maskMoney.js" type="text/javascript"></script>
</head>
<body>
<input type="text" id="currency" />
</body>
<script type="text/javascript">
$(function(){
$("#currency").maskMoney();
})
</script>
The options that you can set are:
symbol
: the symbol to be displayed before the value entered by the user(example: "US$"). default: ''symbolStay
: set if the symbol will stay in the field after the user exists the field. default: falsethousands
: the thousands separator. default: ','decimal
: the decimal separator. default: '.'precision
: how many decimal places are allowed. default: 2defaultZero
: when the user enters the field, it sets a default mask using zero. default: trueallowZero
: use this setting to prevent users from inputing zero. default: falseallowNegative
: use this setting to prevent users from inputing negative values. default: false
We have 2 bonus methods that can be useful to you:
.maskMoney('destroy')
which removes maskMoney from an element..maskMoney('mask')
which causes maskMoney to actually apply the mask to your input.
- Aurélio Saraiva
- Raul Pereira da Silva
- Diego Plentz
- Otávio Ribeiro Medeiros
- Víctor Cruz
- Synapse Studios
- Guilherme Garnier
- Plínio Balduino
- Luis Fernando Gomes
jQuery-maskMoney is released under the MIT license.