5.1.1 • Published 8 years ago

vanilla-text-mask v5.1.1

Weekly downloads
33,893
License
Unlicense
Repository
github
Last release
8 years ago

JavaScript Input Mask

Note: IE9 is not supported in this module.

Getting started

First, install it.

npm i vanilla-text-mask --save

Then, use it as follows:

<script
  type="text/javascript"
  src="./node_modules/vanilla-text-mask/dist/vanillaTextMask.js"></script>
<script type="text/javascript">
  var phoneMask = ['(', /[1-9]/, /\d/, /\d/, ')', ' ', /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/]

  // Assuming you have an input element in your HTML with the class .myInput
  var myInput = document.querySelector('.myInput')

  var maskedInputController = vanillaTextMask.maskInput({
    inputElement: myInput,
    mask: phoneMask
  })
  
  // Calling `vanillaTextMask.maskInput` adds event listeners to the input element. 
  // If you need to remove those event listeners, you can call
  maskedInputController.destroy()
</script>

Documentation

As you can see in the code above, you are passing an object to vanillaTextMask.maskInput(...).

The object takes inputElement, which is the <input/> element that you are masking. It also accepts other values which are documented here.

Example

To see an example of the code running, follow these steps:

  1. Clone the repo, git clone git@github.com:text-mask/text-mask.git
  2. cd text-mask
  3. npm install
  4. npm run vanilla:dev
  5. Open http://localhost:3000

The code of the example is in vanilla/example.

Contributing

We would love some contributions! Check out this document to get started.

5.1.1

8 years ago

5.1.0

8 years ago

5.0.3

8 years ago

5.0.2

8 years ago

5.0.1

9 years ago

5.0.0

9 years ago

4.0.0

9 years ago

3.2.3

9 years ago

3.2.2

9 years ago

3.2.1

9 years ago

3.2.0

9 years ago

3.1.0

9 years ago

3.0.0

9 years ago

2.0.0

9 years ago

1.1.0

9 years ago

1.0.0

9 years ago

0.17.3

9 years ago

0.17.2

9 years ago

0.17.1

9 years ago

0.17.0

9 years ago

0.16.3

10 years ago

0.16.2

10 years ago

0.16.1

10 years ago

0.16.0

10 years ago

0.15.0

10 years ago

0.14.1

10 years ago

0.14.0

10 years ago

0.13.1

10 years ago

0.13.0

10 years ago

0.12.0

10 years ago

0.11.0

10 years ago

0.10.0

10 years ago

0.9.0

10 years ago

0.8.0

10 years ago

0.0.1

10 years ago