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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onChange is not fired when delete last characters #358

Closed
wambaloo opened this issue Oct 29, 2015 · 2 comments
Closed

onChange is not fired when delete last characters #358

wambaloo opened this issue Oct 29, 2015 · 2 comments

Comments

@wambaloo
Copy link

When you delete character by character your string, the last character does not fire the "onChange" event. It's because of this line : "changed = val !== oldValue" in "callbacks" and because the variable "oldValue" is only updated on "blur" event. So when you don't leave the focus on the field, and you type something then you delete this, the last character deleted not fire the "onChange" event. I'm trying to find a fix and I will purpose it to you later.

@wambaloo
Copy link
Author

Something like this could solve the problem :
changed = val !== oldValue || val === oldValue === ''
if you considered that the old value is the original value of the field before you focus on the field.

@igorescobar
Copy link
Owner

Check it out:

$.jMaskGlobals = {
    maskElements: 'input,td,span,div',
    dataMaskAttr: '*[data-mask]',
    dataMask: true,
    watchInterval: 300,
    watchInputs: true,
    watchDataMask: false,
    byPassKeys: [9, 16, 17, 18, 36, 37, 38, 39, 40, 91],
    translation: {
        '0': {pattern: /\d/},
        '9': {pattern: /\d/, optional: true},
        '#': {pattern: /\d/, recursive: true},
        'A': {pattern: /[a-zA-Z0-9]/},
        'S': {pattern: /[a-zA-Z]/}
    }
  };

Just remove the keys you don't want to be ignored on byPassKeys option

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

2 participants