react-input-mask icon indicating copy to clipboard operation
react-input-mask copied to clipboard

Optional characters

Open mdodge-ecgrow opened this issue 2 years ago • 1 comments
trafficstars

Does this library support optional characters? For instance a US zip code is usually in format 99999 but sometimes can be in format 99999-9999.

mdodge-ecgrow avatar Nov 16 '23 04:11 mdodge-ecgrow

I looked at the options and initially thought the charRegex option allowed me to type in my own mask regex, like this:

const { getInputProps: zipCodeInput } = useInputMask({
	charRegex: /^\d{5}(?:-\d{4})?$/
});

But upon further looking, it looks like that option only sets the allowable characters.

mdodge-ecgrow avatar Nov 16 '23 04:11 mdodge-ecgrow