Skip to content

Commit

Permalink
chore: change mask token to numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardovillao committed Jan 9, 2025
1 parent 5a7c9cc commit 65f1389
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
2 changes: 1 addition & 1 deletion assets/js/input-mask.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 16 additions & 19 deletions src/js/input-mask.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ class inputMask {
this.init();
this.mappedMasks = mappedMasks || null;
this.tokens = {
'#': {
'0': {
validateRule: /\d/,
},
'*': {
validateRule: /[a-zA-Z]/,
},
};
}

Expand Down Expand Up @@ -123,9 +120,9 @@ class inputMask {
}

for (let i = 0; i < maskChars.length; i++) {
if (maskChars[i] === '#') {
if (maskChars[i] === '0') {
if (
new RegExp(this.tokens['#'].validateRule).test(
new RegExp(this.tokens['0'].validateRule).test(
unmaskedValue[valueIndex]
)
) {
Expand All @@ -152,66 +149,66 @@ class inputMask {

new inputMask({
'ev-tel': {
mask: '####-####',
mask: '0000-0000',
reverse: false,
inputmode: 'tel',
},
'ev-tel-ddd': {
mask: '(##) ####-####',
mask: '(00) 0000-0000',
reverse: false,
inputmode: 'tel',
},
'ev-tel-ddd9': {
mask: '(##) #####-####',
mask: '(00) 00000-0000',
reverse: false,
},
'ev-tel-us': {
mask: '(###) ###-####',
mask: '(000) 000-0000',
reverse: false,
inputmode: 'tel',
},
'ev-cpf': {
mask: '###.###.###-##',
mask: '000.000.000-00',
reverse: false,
inputmode: 'numeric',
},
'ev-cnpj': {
mask: '##.###.###/####-##',
mask: '00.000.000/0000-00',
reverse: false,
inputmode: 'numeric',
},
'ev-money': {
mask: '###.###.###.###.###,##',
mask: '000.000.000.000.000,00',
reverse: true,
inputmode: 'numeric',
},
'ev-ccard': {
mask: '####-####-####-####',
mask: '0000-0000-0000-0000',
reverse: false,
inputmode: 'numeric',
},
'ev-ccard-valid': {
mask: '##/##',
mask: '00/00',
reverse: false,
inputmode: 'numeric',
},
'ev-cep': {
mask: '#####-###',
mask: '00000-000',
reverse: false,
inputmode: 'numeric',
},
'ev-time': {
mask: '##:##:##',
mask: '00:00:00',
reverse: false,
inputmode: 'numeric',
},
'ev-date': {
mask: '##/##/####',
mask: '00/00/0000',
reverse: false,
inputmode: 'numeric',
},
'ev-date_time': {
mask: '##/##/#### ##:##:##',
mask: '00/00/0000 00:00:00',
reverse: false,
inputmode: 'numeric',
},
Expand Down

0 comments on commit 65f1389

Please sign in to comment.