Socket
Socket
Sign inDemoInstall

text-mask-addons

Package Overview
Dependencies
0
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    text-mask-addons

Addons for Text Mask https://github.com/msafi/text-mask


Version published
Weekly downloads
201K
decreased by-7.33%
Maintainers
1
Install size
34.1 kB
Created
Weekly downloads
 

Readme

Source

Text Mask Addons

These addons are ready-to-use validators and masks that can be used with Text Mask.

Installation

npm i text-mask-addons --save-dev

Dynamic masks

These functions here can be passed as a mask to Text Mask.

createCurrencyMask

createCurrencyMask returns a currencyMask function that will format user input as currency. createCurrencyMask accepts an object with prefix and suffix keys. The default prefix is $ and the default suffix is nothing. So, currencyMask by default will turn an input like 3000 to $3,000.

Usage

import createCurrencyMask from 'text-mask-addons/dist/createCurrencyMask.js'

const currencyMask = createCurrencyMask({
  prefix: '',
  suffix: ' $' // This will put the dollar sign at the end, with a space.
})

// ...then pass `currencyMask` to the Text Mask component

Validators

These functions here can be passed as a validator to Text Mask.

createMmddyyyyValidator

createMmddyyyyValidator returns a function that ensures the user is typing a valid mm/dd/yyyy date.

It accepts a config object with minimumDate and maximumDate, and ensures that the user is typing a valid calendar date between these two dates. It prevents the user from entering any character that would invalidate the date. For example, a month that begins with 2 is prevented.

Usage
import createMmddyyyyValidator from 'text-mask-addons/dist/createMmddyyyyValidator.js'

const mmddyyyyValidator = createMmddyyyyValidator({
  minimumDate: '01/01/1900',
  maximumDate: '12/31/2016'
})

// ...then pass `mmddyyyyValidator` to the Text Mask component

Keywords

FAQs

Last updated on 08 Jul 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc