Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ptheofan/cool.inputfilter

jQuery widget that filters user input on textboxes
https://github.com/ptheofan/cool.inputfilter

Last synced: about 2 months ago
JSON representation

jQuery widget that filters user input on textboxes

Awesome Lists containing this project

README

        

FiterInput
author Paris Theofanidis ([email protected])
source https://github.com/ptheofan/cool.inputFilter
demo http://yeeha.pro/demo/textInput/

Fiter user input in textbox in during keyDown and keyPress events, thus
artifact free. This widget will properly handle selected text and paste events.

Tested Under: Chrome, Safari, FireFox, IE8, IE9

Options
regex: A RegExp object which will be used for testing. If null a validate
event will be fired.

Events:
beforeValidate -- an ideal place to remap user input
validate -- when a regex is not enough
afterValidate -- an ideal place to apply logic validation, beyond regex and keystrokes
KeyUp (overrides default) -- an ideal place to update your elements should you need to

Regexes Cheatsheet (make pull requests should you want to add more)
UNSIGNED float with 2 decimal points max
^\d*$|^\d*(\.|\,)\d{0,2}$

Example
$('#myTextbox').inputFilter({regex: new RegExp('^\\d*$|^\\d*(\\.|\\,)\\d{0,2}$')});