# input-pattern-restrictor

> Restrict event propagation into input-like elements by validating the inputted value via regex.

Latest version **1.0.0** (published 2018-04-13) · ISC license · 0 weekly downloads

## Install

```sh
npm install input-pattern-restrictor
pnpm add input-pattern-restrictor
yarn add input-pattern-restrictor
bun add input-pattern-restrictor
```

## 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 | 1.0.0 |
| Published | 2018-04-13 |
| First published | 2018-04-13 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 75.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | korynunn |

## Links

- npm: https://www.npmjs.com/package/input-pattern-restrictor
- Repository: https://github.com/KoryNunn/input-pattern-restrictor
- Homepage: https://github.com/KoryNunn/input-pattern-restrictor#readme
- Issues: https://github.com/KoryNunn/input-pattern-restrictor/issues
- npm.io page: https://npm.io/package/input-pattern-restrictor

## Dependencies (4)

- [doc-js](https://npm.io/package/doc-js.md) ^1.3.1
- [setify](https://npm.io/package/setify.md) ^1.0.3
- [fire-html-event](https://npm.io/package/fire-html-event.md) ^1.0.0
- [natural-selection](https://npm.io/package/natural-selection.md) ^1.0.0

## Recent versions

- 1.0.0 (latest) — 2018-04-13

## README

# input-pattern-restrictor
Restrict event propagation into input-like elements by validating the inputted value via regex.

## Usage
```javascript
var inputPatternRestrictor = require('input-pattern-restrictor');

window.onload = function() {

    function restrictInput(event){
        inputPatternRestrictor(event, /^\d{0,2}\s?\d{0,3}\s?\d{0,3}\s?\d{0,3}$/);
    }

    element.addEventListener('keypress', restrictInput);
    element.addEventListener('paste', restrictInput);
};
```

## Example
npm run example

---
_Source: https://npm.io/package/input-pattern-restrictor · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
