Skip to content
This repository has been archived by the owner on May 3, 2021. It is now read-only.

pedroprado010/mask-me

Repository files navigation

Mask Me

Total alerts Language grade: JavaScript

Framework neutral input masking.

Installing

npm install --save @plcsp/mask-me

Using it

import MaskMe function and pass it a mask string.

import MaskMe from 'mask-me'
// or
var MaskMe = require('mask-me')

var myMask = MaskMe('00/00/000')

Special chars

  • # : loop char
var myMask = MaskMe('.#')
myMask('000') // returns .0.0.0
  • A: accepts alphabetical chars
  • S: accepts alphanumeric
  • 0: accepts numeric
  • 9: accepts numeric, but its optional (will pass to next test if receive a non numeric)

Options

Choose direction where mask will start parsing.

var myMask = MaskMe('##.00', {startAt: 'right'}) // default is left

Examples

var moneyMask = MaskMe('##.#0,00', {startAt: 'right'})
moneyMask(11122233344455) // 111.222.333.444,55
var dateMask = MaskMe('00/00/0000')
dateMask(20112000) // 20/11/2000
var ipMask = MaskMe('990.990.990.990')
ipMask('192180 100') // 192.168.0.100

License

This project is licensed under the MIT License - see the LICENSE.md file for details

About

Neutral framework mask functions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published