imaskjsvanilla javascript input mask

Features

  • get and set value and unmasked value easily
  • no external dependencies
  • Supports all major browsers and IE11+ *need older?
  • RegExp mask
  • Function mask
  • Number mask (integer and decimal support)
  • Date mask (with various format support)
  • Dynamic/on-the-fly mask
  • Pattern mask
    • show placeholder always or when needed
    • unmasked value can contain fixed parts
    • optional input parts (greedy)
    • custom definitions
    • reusable groups
  • React/Angular/Vue plugins
var regExpMask = new IMask(
  document.getElementById('regexp-mask'),
  {
    mask: /^[1-6]\d{0,5}$/
  });
learn more
unmasked:
var phoneMask = new IMask(
  document.getElementById('phone-mask'), {
    mask: '+{7}(000)000-00-00'
  });
learn more
number:
var numberMask = new IMask(
  document.getElementById('number-mask'),
  {
    mask: Number,
    min: -10000,
    max: 10000,
    thousandsSeparator: ' '
  });
learn more
date:
var dateMask = new IMask(
  document.getElementById('date-mask'),
  {
    mask: Date,
    min: new Date(2000, 0, 1),
    max: new Date(2020, 0, 1),
    lazy: false
  });
learn more
unmasked:
var dynamicMask = new IMask(
  document.getElementById('dynamic-mask'),
  {
    mask: [
      {
        mask: '+{7}(000)000-00-00'
      },
      {
        mask: /^\S*@?\S*$/
      }
    ]
  });
learn more

I'm happy to present you one of the best JS libraries for the user input formatting. My goal is to create the most simple, convenient and yet extensible API, which I think I achieved as possible. Also with a great support of the community plugins for the major JS frameworks were created.

I've been working on my own enthusiasm for more than a year, not receiving any payment for my work. I've been thanked by about 5 people and even one man made a donation. This support is very important for me. Thank you.

Right now I would like to proceed with several new features, but I would like to get some feedback from the community. Please vote on issue which is important to you and you can always support and speed up the development process by making a donation - this way I will be sure that my work matters to someone.

Further Plans

In any case, I'm going to continue fixing bugs, updating the dependencies and maintaining the repo in general.