1.0.4 • Published 7 years ago
ts-mask v1.0.4
ts-mask
Typescript input mask
Install
npm install ts-mask
Usegate
Mask
Mask is the mixed array of RegExp and strings One item of array corresponds to one character of string.
Class
Class constructor has got only two parameters: input: HTMLInputElement mask: (RegExp | string)[]
Example
component.html
<input type="text" id="text-input" />
component.ts
let phoneMask: (string | RegExp)[] = ['+','7',' ','(',/\d/,/\d/,/\d/,')',' ',/\d/,/\d/,/\d/,'-',/\d/,/\d/,/\d/,/\d/];
new TSMask(<HTMLInputElement>document.getElementById('text-input'), phoneMask);