MaskedInputPlus
A React component for <input>
masking,
forked from react-masked-input
and built on top of inputmask-core.
Additional feature: ability to paste strings with any allowed space-characters or without it.
Install
npm
npm install react-maskedinput-plus --save
Usage
Give MaskedInput
a pattern
and an onChange
callback:
This widget can accept +7123-123-12-12, 71231232323, 7 (123) 123-23-23, +7123 123 23 23, etc...
const PHONE_PATTERN = '+1 111 111 11 11'const NON_DATA_MASK = '[^\\d]+'const NON_DATA_PATTERN = NON_DATA_MASKconst UNKNOWN_COUNTRY = 'UNKNOWN' : string { const formatted = phone const result = e164 return result ? resultcode : UNKNOWN_COUNTRY} Component { const id name onChange value } = thisprops return <MaskedInput className= id =id name=name onChange=onChange pattern=PHONE_PATTERN nonDataMask = NON_DATA_MASK validate= !== UNKNOWN_COUNTRY size="17" value=value /> }