Simple module that provides a mask to enter field.
document.querySelectorAll('input[data-mask]').forEach(function(val, key) {
new Mask(val);
});
<input type="text" value="" data-mask="+7 (___) - ___ - __ - __"/>
new Mask(document.querySelector('input[data-mask]'), {
prefix: '_',
keyIgnore: [8,37,39,46],
callback: {
success: function (input) {
console.log('success');
},
error: function (input) {
console.log('error');
}
}
});
- setPlaceholder: Set placeholder for input.
- prefix: Template for characters.
- keyIgnore: Keys to avoid.
- callback.success: Callback to execute when the input verification success.
- callback.error: Callback to execute when the input verification error.