Hi.
Im using ([a-zA-Z\s])+ to get an only letters input mask but only accept one character.


Hi @fdorantesm, I think the mask prop of the MaskedInput component accepts an array of regular expressions that match a single character each, while your regular expression matches any number of characters.
For your use case you could consider passing a mask function instead.
Try with:
<ReactTextMask
mask={s => Array.from(s).map(() => /[a-z]/i)}
guide={false}
/>
Notice that we set guide to false so that when a newly added character does not match our regular expression it is not added to the input as an empty placeholder (e.g., _).
Have a look at the docs for more info ;)
Most helpful comment
Hi @fdorantesm, I think the
maskprop of theMaskedInputcomponent accepts an array of regular expressions that match a single character each, while your regular expression matches any number of characters.For your use case you could consider passing a mask function instead.
Try with:
Notice that we set
guidetofalseso that when a newly added character does not match our regular expression it is not added to the input as an empty placeholder (e.g.,_).Have a look at the docs for more info ;)