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

masked element's "change" event ignored when using "reverse" option #3

Closed
khafancoder opened this issue Jun 10, 2012 · 15 comments
Closed
Labels

Comments

@khafancoder
Copy link

after applying masks which includes separator chars with the reverse option=true, the input's "change" event would not be triggered anymore :

$("#input1").mask("999,999,999", { reverse: true });
$("#input1").change(function()
{
alert("value changed"); //ignored
});

@igorescobar
Copy link
Owner

Hi! @khafancoder

Well, this is interesting. I'm using event namespaces (http://api.jquery.com/event.namespace/) exclusively to not cause conflict. I will investigate this bug and I will try to fix it as soon as possible!

Thank you!

Igor
[]'s

@igorescobar
Copy link
Owner

Hi @khafancoder!
I think this issue is already fixed. Could you please confirm it for me?

@khafancoder
Copy link
Author

Dear @igorescobar

I think the problem still exists, you can use the above code and entering "111111" into the text input.

I've noticed the bug also occurs in some other case even the reverse option has not been used. for example:

$("#input1").mask("999,999,999", { reverse: false});
$("#input1").change(function()
{
alert("value changed"); //ignored
});

entering "1111" into the text input doesn't fire the change event.

@igorescobar
Copy link
Owner

Are you using jQuery mask with whitch version of jQuery?

@khafancoder
Copy link
Author

I've tested it with jQuery 1.5.1 & 1.8.1

@igorescobar
Copy link
Owner

@khafancoder
And are you experiencing the same results with jQuery 1.8? I think maybe this is a problem of jQuery 1.5 because I've tested with jQuery 1.6, 1.7 and 1.8 and I can't reproduce this issue. Maybe if you provide a jsfiddle with the code that you're having trouble would be better to identify the problem.

@khafancoder
Copy link
Author

http://jsfiddle.net/ZbWpJ/3/

after testing with other browsers it seems that Firefox hasn't any problem with that, but the bug occurs in Google Chrome (v21.0) and IE (v8)

@igorescobar
Copy link
Owner

I will be doing a new roll of tests arround this issue but after doing a little research around this problem it seems to have a lot of people having troubles with jquery change. (http://api.jquery.com/change/)
I'll try to discover a workarround to "minimize" this problem but I think this is not going to be pretty. Sounds more like a a jQuery bad implementation around the onchange event.

Wish me luck!

@igorescobar
Copy link
Owner

Problem solved, new version was generated, have fun! ;)

@khafancoder
Copy link
Author

thanks a lot

@renatovico
Copy link

i tested in version 1.3.0 and nothing happens :(

@marceloodiniz
Copy link

I'm having the same problem...
I'm using jQuery 1.11.0, Jquery Mask v1.5.3
My browser is Google Chrome version 32.0.1700.102 m
This is my mask: "0.000.000,00" (with reverse enabled)

@swimitup
Copy link

Seem to be a quite long this issue has been discovered, but please pay attention to your default value or to the maxlength property of the input.
ex: i had an input for hour (hh:mm) that was receiving 14:00:00 as default value (... $(".horario").mask("00:00").
the jquery did not trigger if you try to change the hour (13:00) but it will trigger if you change the minutes (14:01). by accident i discovered that somehow the change was not triggered in the masked field because the masked field was returning 00:00 (the last 5 chars), not 15:00 (the 5 firts chars), hence there was no reason for jquery trigger the change in the input...
not sure if it's a bug, but i spend 3h on this. hope it helps somebody else's work.

@mscarchilli
Copy link

Having this same exact problem in Chrome with v1.13.4. Using jQuery v1.11.0 The comma is where it breaks. 3 numbers the on change event works, anything more it does not.

Usage:

$(".elm").mask("000,000", {reverse: true});

I even tried using another method, but the reverse set to true breaks it this way as well.

$('.elm').mask('NNNcNNN', {
    'translation': {
      N: {
        pattern: /[0-9]/
      },
      c: {
        pattern: /[,]/,
        fallback: ','
      }
    },
    reverse: true
  });

Best alternate solution I could come up with was to add an onchange event directly on the element that points to a function in the JavaScript.

@odenirdev
Copy link

i have the same problem in jquery v3.5.0 and jquery-mask v1.14.16

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

No branches or pull requests

7 participants