Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/json2d/jquery.input-allow
A jQuery plugin that provides lightweight unobtrusive real-time regEx filtering for individual characters entered into input fields.
https://github.com/json2d/jquery.input-allow
Last synced: 26 days ago
JSON representation
A jQuery plugin that provides lightweight unobtrusive real-time regEx filtering for individual characters entered into input fields.
- Host: GitHub
- URL: https://github.com/json2d/jquery.input-allow
- Owner: json2d
- License: mit
- Created: 2015-11-12T09:36:27.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-11-12T09:40:30.000Z (about 9 years ago)
- Last Synced: 2023-03-01T18:55:49.828Z (almost 2 years ago)
- Language: JavaScript
- Size: 0 Bytes
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# jquery.input-allow v0.1
*by Jason Yung - [http://callmejay.com](http://callmejay.com "http://callmejay.com")*A [jQuery](http://jquery.com) plugin that provides lightweight unobtrusive real-time regEx filtering for individual characters entered into input fields.
### Basic Usage
Simply use the **allow** attribute on any **input** tag to specify a regEx to filter by.
```html
```
### Dynamic Content Support
The plugin uses `$('body').delegate(...)` to bind its core handlers to any and every **input** tag that has an **allow** attribute defined, including those added dynamically:
```javascript
$('body').append(""); //works out of the box!
```
### Events
Each character entered into a filtered input field is compared to some regEx:- If a character matches, the **input** element will trigger an **input-allow.pass** event
- If a character does not match, the **input** element will trigger an **input-allow.fail** eventTo bind a handler to these events, you can use `on` or `delegate`:
```javascript
$('input[allow]').on('input-allow.fail', function(event) {
event.target.css('background','red'); //input was bad - color the element red
});// dynamic content support
$('body').delegate('input-allow.pass', 'input[allow]',function(event){
event.target.css('background','green'); //input was good - color the element green
});
```
### Known Issues
- Edge cases were not really considered.### Roadmap
TODO