Strange behavior when switching between masks
See original GitHub issueI am trying to use two masks, one for American Express credit cards (9999 999999 99999) and one for everything else (9999 9999 9999 9999).
I almost have it, but I’m having a strange problem: as you can see below, when I type 37 the mask switches properly to the Amex one. However, when I erase the 7 and change it to an 8 to make the mask switch back, the 3 disappears.
Am I doing something wrong? Thanks for the help.
$.extend($.inputmask.defaults.definitions, {
'a': { // matches 37 and 34, amex prefixes
"validator": "3(4|7)",
"cardinality": 2,
'prevalidator': [{ validator: "3", cardinality: 1 }]
},
'o': { // matches two-digit number except 34 and 37
"validator": function (chrs, buffer, pos, strict, opts) {
return /\d\d/.test(chrs) && chrs != "34" && chrs != "37";
},
"cardinality": 2,
'prevalidator': null
}
});
$('#x').inputmask({
mask: ["o99 9999 9999 9999", "a99 999999 99999"]
});
Issue Analytics
- State:
- Created 9 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
How to resist peer pressure when you're the only one wearing ...
Going against the norm can make people feel distressed and anxious, said Yellowlees, even if no one uses spoken or direct peer pressure...
Read more >Wearing a Mask Can Change Your Behavior - SciTechDaily
One hypothesis, Lu notes, is that “masks can disinhibit wearers' deviant behavior by increasing anonymity,” making people “more likely to engage ...
Read more >How do masks change human behavior? An Italian scientist ...
Research he and others have done suggests that masks — even ones that are handmade — significantly lower the likelihood of transmission of...
Read more >“Responsible” or “Strange?” Differences in Face Mask ...
In sum, the findings from Study 1 reflect particularly favorable perceptions of mask wearers among the Chinese Canadians, and ambivalent, yet ...
Read more >It's Gotten Awkward to Wear a Mask - The Atlantic
For some members of the maskless majority, feeling like “the normal ones” again could even serve to legitimize insulting, dismissive, or ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
LICEcap
A coworker showed it to me and I was immediately addicted. It is incredible.
Now possible. Consider your field has this ID #cc
`$(“#cc”).on(“input”, function() { var value = $(“#cc”).val().replace(/\D/g, ‘’); var mask; if ((/^3[47]\d{0,13}$/).test(value)) { // American Express mask = ‘9999 999999 99999’ } else if ((/^3(?:0[0-5]|[68]\d)\d{0,11}$/).test(value)) { // Diner’s Club mask = ‘9999 999999 9999’ } else if ((/^\d{0,16}$/).test(value)) { // Other Credit Cards mask = ‘9999 9999 9999 9999’ } else { mask = ‘remove’ }
if($(‘#cc’).attr(‘data-currentmask’) != mask) { $(‘#cc’).attr(‘data-currentmask’, mask); $(‘#cc’).inputmask(mask, { placeholder: ‘’ }); } });`
I found this solution here