JSPM

  • Created
  • Published
  • Downloads 2320
  • Score
    100M100P100Q119505F
  • License ISC

Simple money mask developed with pure JavaScript

Package Exports

  • simple-mask-money

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (simple-mask-money) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

SimpleMaskMoney

build Status npm version npm Downloads dependencies Status

NPM

Simple money mask developed with pure JavaScript. Try live demo

Getting Started

First, install it.

  npm i simple-mask-money --save

Then, use it as follows:

  <body>
    <!-- 
      inner html you put type text and inputmode numeric to mobile show numeric keyboard 
     -->
    <input inputmode="numeric" oninput="this.value = SimpleMaskMoney.format(this.value)" onkeyup="send()" value="0,00"><br>

    <script src="./node_modules/simple-mask-money/lib/simple-mask-money.js"></script>
    <script>
      // select the element 
      let input = document.getElementsByTagName('input')[0];

      // configuration  
      SimpleMaskMoney.args = {
        preffix: '',
        suffix: '',
        fixed: true,
        fractionDigits: 2,
        decimalSeparator: ',',
        thousandsSeparator: '.',
        autoCompleteDecimal: false
      };

      // Your send method 
      send = () => {

        // This method return value of your input in format number to save in your database
        SimpleMaskMoney.formatToNumber(input.value);
      }
    </script>
  </body>