Skip to content

Changed seems wrong #486

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

Closed
felipedrumond opened this issue Dec 5, 2016 · 1 comment
Closed

Changed seems wrong #486

felipedrumond opened this issue Dec 5, 2016 · 1 comment

Comments

@felipedrumond
Copy link

felipedrumond commented Dec 5, 2016

When I have "5.000,00" as the current value, the oldValue is 500,00. If I press backspace, val will be 500,00; which is equal to oldValue, so that changed will not be true.

I added the following line of code to fix it:

callbacks: function (e) {
                var val = p.val(),
                    changed = val !== oldValue, <-- this line will be afected by the change below
                    defaultArgs = [val, e, el, options],
                    callback = function (name, criteria, args) {
                        if (typeof options[name] === 'function' && criteria) {
                            options[name].apply(this, args);
                        }

                        oldValue = val; // CODE ADDED
                    };

                callback('onChange', changed === true, defaultArgs);
                callback('onKeyPress', changed === true, defaultArgs);
                callback('onComplete', val.length === mask.length, defaultArgs);
                callback('onInvalid', p.invalid.length > 0, [val, e, el, p.invalid, options]);
            }
@igorescobar
Copy link
Owner

@felipedrumond why don't you submit a PR with that and we can discuss in there? Thanks!

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