Usage Mask Details

mask

Mask format. Can be either a string or array of characters and regular expressions.

mask('130499', "99/99/99")

Simple masks can be defined as strings. The following characters will define mask format:

CharacterAllowed input
90-9
aa-z, A-Z
*0-9, a-z, A-Z

Any format character can be escaped with a backslash.

More complex masks can be defined as an array of regular expressions and constant characters.

// Canadian postal code mask
const firstLetter = /(?!.*[DFIOQU])[A-VXY]/i;
const letter = /(?!.*[DFIOQU])[A-Z]/i;
const digit = /[0-9]/;
const mask = [firstLetter, digit, letter, " ", digit, letter, digit];