jquery.inputfilter
Version:
jQuery plugin for adding filters to forms input and textarea, like numeric input only.
43 lines (31 loc) • 1.01 kB
Markdown
jQuery plugin for adding filters to forms input and textarea, like numeric input only.
```bash
npm install jquery.inputfilter
```
import after jquery and configure `inputfilter()` to the jquery elements you want to apply filter
```js
import $ from "jquery";
import "jquery.inputfilter";
// Standard options
$("input, textarea").inputfilter();
// Set options
const options = { allowNumeric: true, allowText: true };
$("input, textarea").inputfilter(options);
```
```js
const options = {
allowNumeric: true, // is numbers allowed [0-9]
allowText: false, // is text allowed [a-z|A-Z]
allowEnter: true, // is Enter allowed
allowCustom: [], // Array of chars to allow
regex: null, // Regular expression of allowed chars
maxLength: null, // Numeric value representing the maximum number of chars permitted
actionLog: false, // Log actions
};
```
Copyright © 2015 Anders Fjällström, licensed under the MIT License