jQuery-Mask-Plugin icon indicating copy to clipboard operation
jQuery-Mask-Plugin copied to clipboard

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

Open khafancoder opened this issue 14 years ago • 15 comments

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

khafancoder avatar Jun 10 '12 21:06 khafancoder

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 avatar Jun 11 '12 11:06 igorescobar

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

igorescobar avatar Aug 31 '12 02:08 igorescobar

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.

khafancoder avatar Aug 31 '12 21:08 khafancoder

Are you using jQuery mask with whitch version of jQuery?

igorescobar avatar Aug 31 '12 22:08 igorescobar

I've tested it with jQuery 1.5.1 & 1.8.1

khafancoder avatar Aug 31 '12 22:08 khafancoder

@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.

igorescobar avatar Aug 31 '12 22:08 igorescobar

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)

khafancoder avatar Aug 31 '12 23:08 khafancoder

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 avatar Sep 01 '12 00:09 igorescobar

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

igorescobar avatar Sep 04 '12 01:09 igorescobar

thanks a lot

khafancoder avatar Sep 05 '12 07:09 khafancoder

i tested in version 1.3.0 and nothing happens :(

renatovico avatar Sep 23 '13 19:09 renatovico

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)

marceloodiniz avatar Feb 02 '14 18:02 marceloodiniz

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.

swimitup avatar May 12 '15 02:05 swimitup

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.

mscarchilli avatar Nov 24 '15 20:11 mscarchilli

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

odenirdev avatar Jul 29 '20 22:07 odenirdev