Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

On-the-fly mask change on mobile devices #751

Open
nmbrone opened this issue Jun 18, 2020 · 0 comments
Open

On-the-fly mask change on mobile devices #751

nmbrone opened this issue Jun 18, 2020 · 0 comments

Comments

@nmbrone
Copy link

nmbrone commented Jun 18, 2020

Hi there 馃憢

Device

iPhone

Browser (and version)?

Safary/Chrome

Describe de problem depth:

I'm using the plugin like in the code example

var mask0 = '0000 0000 0000 0000 000';
var mask1 = '0000-0000-0000-0000';
var mask2 = 'DDDD DDDD DDDD DDDD DDD';

input.mask(mask0, {
  translation: {
    0: { pattern: /[A-Za-z0-9]/ },
    D: { pattern: /[0-9]/ }
  },
  onKeyPress: (val, e, field, options) => {
    var mask;
    if (val === '') {
      mask = mask0;
    } else if (/^123/.test(val)) {
      mask = mask2;
    } else {
      mask = mask1;
    }
    input.mask(mask, options);
  }
});

and it works great, but the only problem is that on mobile devices when a user pasting the copied value into the masked field the next error occurs

TypeError: undefined is not an object (evaluating 'p.maskDigitPosMapOld[i]')

if (p.maskDigitPosMapOld[i]) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant