Define a Mask
mainA mask is an array where each item defines one character of the value.
- Use a string for static characters (e.g.,
'-',' ','('). - Use a RegExp for characters that the user inputs (e.g.,
/\d/for digits).
Note: All characters intended to be input by the user must be a RegExp in your mask array.
const zipCodeMask = [/\d/, /\d/, /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/];