# @formio/vanilla-text-mask

> JavaScript function that makes input HTML element accept mask pattern

Latest version **5.1.1-formio.1** (published 2022-09-13) · Unlicense license · 0 weekly downloads

## Install

```sh
npm install @formio/vanilla-text-mask
pnpm add @formio/vanilla-text-mask
yarn add @formio/vanilla-text-mask
bun add @formio/vanilla-text-mask
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.1.1-formio.1 |
| Published | 2022-09-13 |
| First published | 2021-04-19 |
| Weekly downloads | 0 |
| License | Unlicense |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 118.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8204 |
| Author | M.K. Safi |
| Maintainers | lane-formio, tanyagashtold, edwinanciani, travist |
| Keywords | text mask, input mask, string mask, input formatting, text formatting, string formatting |

## Links

- npm: https://www.npmjs.com/package/@formio/vanilla-text-mask
- Repository: https://github.com/text-mask/text-mask
- Homepage: https://github.com/text-mask/text-mask/tree/master/vanilla/#readme
- Issues: https://github.com/text-mask/text-mask/issues
- npm.io page: https://npm.io/package/@formio/vanilla-text-mask

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 5.1.1-formio.1 (latest) — 2022-09-13
- 5.1.1 — 2021-04-19

## README

# JavaScript Input Mask

**Note:** IE9 is not supported in this module.

## Getting started

First, install it.

```bash
npm i vanilla-text-mask --save
```

Then, use it as follows:

```html
<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](https://github.com/text-mask/text-mask/blob/master/componentDocumentation.md#readme).

## 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`
1. `cd text-mask`
1. `npm install`
1. `npm run vanilla:dev`
1. Open [http://localhost:3000](http://localhost:3000)

The code of the example is in [`vanilla/example`](https://github.com/text-mask/text-mask/tree/master/vanilla/example).

## Contributing

We would love some contributions! Check out [this document](https://github.com/text-mask/text-mask/blob/master/howToContribute.md#readme) to get started.

---
_Source: https://npm.io/package/@formio/vanilla-text-mask · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
