input-pattern-restrictor
v1.0.0
Published
Restrict event propagation into input-like elements by validating the inputted value via regex.
Downloads
8
Readme
input-pattern-restrictor
Restrict event propagation into input-like elements by validating the inputted value via regex.
Usage
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