Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- document.getElementById('input').addEventListener('keydown',function(event){
- event.preventDefault();
- var stateTree = {
- 0 : ['-','+','[0-9]'],
- ... // basicly declare here possible regexp's per length
- };
- var text = this.value +''+ event.key;
- var array = stateTree[text.length];
- array.map( function(item){
- const match = new RegExp(item, 'g');
- if( text.match(match) ){ this.value = text }
- });
- })
Add Comment
Please, Sign In to add comment