Maskit

Demo form

            
              // 0 any number
              // A any char
              // Ы any cyrillic char
              // ?+-()[]{}.,\\/-=_~`|'" autofilled chars

              // also you can wrap any symbol in brackets "{someChar}",
              // and it will be autofilled In other cases mask will be
              // waiting for same char

              // Usage:

              //npm i --save 'maskit'

              import Maskit from 'maskit';

              let input = document.querySelector('input.masked'),
                mask = new Maskit(input, {
                  mask: '',
                  notFilledClear: true, // clear input on leave the focus if mask is not filled
                  onFilled: scope => {}, // starts when mask is filled
                  offFilled: scope => {}, // starts when mask is not filled
                  onBlur: scope => {}, // starts when input has left the focus
                  beforeChange: ({scope, value}) => {} // run before change flow, to set dynamic mask, etc.
                  onChange: scope => {} // starts when input is changed
                  onInit: scope => {} // starts when mask initialize
                });
              // if you need to change mask of input
              // mask.setMask(newMask);