Stringmask-js
A tiny javascript library to mask strings
Instalation
npm i stringmask-js -s
or
yarn add stringmask-js
Examples
Phone number
"12726323132"; // (12) 7263-23132
Only numbers
"12312312W"; // 12312312
Date
"19981001"; // 1998-10-01
CPF
"12345678910"; // 123.456.789-10
Special Characteres
- 0 - Numbers
- $ - Any caractere (if is the last charactere it will repeat the previous Special Character forever)
- A - Alphanumerics
- S - Letters
- U - Letters (it will transform any letter to upper case)
- L - Letters (it will transform any letter to lower case)
Mask inputs with React
const MaskedInput = props const mask cleaner value: _ ...rest = props; const value setValue = ; ; return <input = /> ... <MaskedInput ="phone" = = ="(00) 0000-00000" =/>