Skip to content

Changed seems wrong #486

Closed
Closed
@felipedrumond

Description

@felipedrumond

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]);
            }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions