#6686 closed bug (invalid)
IE8 Change Event issue with Jquery 1.4.2
Reported by: | budigelli | Owned by: | budigelli |
---|---|---|---|
Priority: | undecided | Milestone: | 1.4.2 |
Component: | event | Version: | 1.4.2 |
Keywords: | needsreview, IE8 textbox change | Cc: | [email protected]… |
Blocked by: | Blocking: |
Description
This issue is specific to 1.4.2 and fine with 1.3.2.
I have textbox with some watermark applied and as I go in and out of it, with out changing any text, it is raising onchange on IE8.
You could simply produce this with jQuery watermark plugin http://digitalbush.com/projects/watermark-input-plugin/
Here is whats happening.
- Load textbox with empty/blank value.
- Wireup an event handler for focus event that clears the value if its not the watermark value we provided
- Wireup an event handler for blur event that puts watermark value in to the textbox if the value is not empty.
- Wireup an event handler to do same as blur event
- Set some watermark value to this textbox using JS.
Here is whats happening:
- Page loads with textbox
- JS plug-in puts in watermark value in to the textbox (No on change fires)
- On focus, JS plug-in clears watermark value.
- On blur, JS plug-in puts the watermark value back.
IE fires change event at this time; Firefox does not. As IE fires Change event before blur. This same code worked in jQuery 1.3.2.
This is from Microsoft documentation... http://msdn.microsoft.com/en-us/library/ms536912(VS.85).aspx
They quote "This event is fired when the contents are committed and not while the value is changing. For example, on a text box, this event is not fired while the user is typing, but rather when the user commits the change by leaving the text box that has focus. In addition, this event is executed before the code specified by onblur when the control is also losing the focus."
Change History (6)
comment:1 Changed 13 years ago by
Component: | unfiled → event |
---|
comment:2 follow-up: 3 Changed 13 years ago by
Example of a better technique: http://scott.sauyet.com/Javascript/Demo/Overlabel/
comment:3 Changed 13 years ago by
Replying to dmethvin:
Hi Dmethvin, Thank you for your prompt response. I took a quick look at your alternative and It does not seem to work on fields that already have labels for them.
For most of the fields I am applying the watermark for already have labels.
Date : [TextBox1] and watermark is usually the format of accepted date.
So, "Date" is already a label for [TextBox1]. With your proposed technique, I would need to have two labels one with properly marked class. For long forms, we could end up with lot of extra mark up.
Thanks for pointing out that link though. Nice trick. I will keep it in mind going forward.
comment:4 Changed 12 years ago by
Owner: | set to budigelli |
---|---|
Priority: | → undecided |
Status: | new → pending |
Please provide a reduced jsFiddle test case, thanks!
Additionally, test against the jQuery 0 GIT version to ensure the issue still exists.
comment:5 Changed 12 years ago by
Keywords: | needsreview added |
---|
comment:6 Changed 12 years ago by
Resolution: | → invalid |
---|---|
Status: | pending → closed |
Automatically closed due to 14 days of inactivity.
Just for some more background, the W3C says this:
I'm not sure if the W3C specifies the order in which the blur/change events should fire, although Microsoft does as you pointed out.
Most likely, this behavior change was introduced when fixing the problem that IE's native change event doesn't bubble, although the W3C says it should. Original commit for that is here: http://github.com/jquery/jquery/commit/5dc6b7ce3469eaadb37a151d449e8d36571d1894
As for the plugin, a better approach would be to layer an element over the empty input with the hint. Changing the actual content may confuse form fillers, since they will "see" your hints as input.