vue-input-mask

Masked input component for Vue
24,465 14
Install
npm install vue-input-mask
Latest Version:0.0.11
Vue:2
License:MIT
Last Updated:Dec 10, 2022
Links: GitHub  ·  npm
Maintainer: xdimedrolx

vue-input-mask

Yet another Vue component for input masking. Based on react-input-mask.

Demo

Install

yarn add vue-input-mask
or
npm i -S vue-input-mask

Properties

mask : string

Mask string. Default format characters are: 9: 0-9 a: A-Z, a-z *: A-Z, a-z, 0-9

Any character can be escaped with a backslash. It will appear as a double backslash in JS strings. For example, a German phone mask with unremoveable prefix +49 will look like mask="+4\9 99 999 99" or mask={'+4\\9 99 999 99'}

maskChar : string

Character to cover unfilled parts of the mask. Default character is "_". If set to null or empty string, unfilled parts will be empty as in ordinary input.

formatChars : object

Defines format characters with characters as a keys and corresponding RegExp strings as a values. Default ones:

{
  '9': '[0-9]',
  'a': '[A-Za-z]',
  '*': '[A-Za-z0-9]'
}

alwaysShowMask : boolean

Show mask when input is empty and has no focus.

Example

import Vue from 'vue';
import InputMask from 'vue-input-mask';

Vue.component('input-mask', InputMask)

In template:

    <input-mask v-model="value" mask="+4\9 99 999 99" maskChar=" "></input-mask>

Todo

  • Refactoring
  • Tests
  • Implementation of componentWillReceiveProps

Thanks

Thanks @sanniassin for the awesome component

Related Packages

vue-masked-input

Masked input component for Vue.js 2.X

449,387 451
@justfork/maska

Simple zero-dependency input mask for Vue.js and vanilla JS

4,780 2,021
vue-3-mask

A mask library for input fields in Vue.js 3

106,849
ionic-vue-input-mask

Uma biblioteca para adicionar máscaras a campos de entrada Vue.

500
vue-imask

Vue input mask

1,807,737 5,181

Version History

Version Released License
0.0.11 MIT
0.0.10 MIT
0.0.9 MIT
0.0.8 MIT
0.0.7 MIT