imaskjsvanilla javascript input mask

on Github

Features

Plugins

IMask(
  document.getElementById('regexp-mask'),
  {
    mask: /^[1-6]\d{0,5}$/
  }
)
learn more
unmasked:
IMask(
  document.getElementById('phone-mask'),
  {
    mask: '+{7}(000)000-00-00'
  }
)
learn more
value:
IMask(
  document.getElementById('ssn-mask'),
  {
    mask: 'XXX-XX-0000',
    definitions: {
      X: {
        mask: '0',
        displayChar: 'X',
        placeholderChar: '#',
      },
    },
    lazy: false,
    overwrite: 'shift',
  }
)
learn more
number:
IMask(
  document.getElementById('number-mask'),
  {
    mask: Number,
    min: -10000,
    max: 10000,
    thousandsSeparator: ' '
  }
)
learn more
date:
IMask(
  document.getElementById('date-mask'),
  {
    mask: Date,
    min: new Date(1990, 0, 1),
    max: new Date(2020, 0, 1),
    lazy: false
  }
)
learn more
unmasked:
IMask(
  document.getElementById('dynamic-mask'),
  {
    mask: [
      {
        mask: '+{7}(000)000-00-00'
      },
      {
        mask: /^\S*@?\S*$/
      }
    ]
  }
)
learn more
unmasked:
IMask(
  document.getElementById('currency-mask'),
  {
    mask: '$num',
    blocks: {
      num: {
        // nested masks are available!
        mask: Number,
        thousandsSeparator: ' '
      }
    }
  }
)
learn more
masked:
IMask.createPipe(
  phoneMask.masked,
  IMask.PIPE_TYPE.UNMASKED,
  IMask.PIPE_TYPE.MASKED
)
learn more