Device-Bugs icon indicating copy to clipboard operation
Device-Bugs copied to clipboard

iOS5 datepickers don't fire onchange

Open paulirish opened this issue 12 years ago • 5 comments

Summary:

Mobile Safari on iOS5 does not fire the change event when a new date/time is selected with the native picker.

Platforms Affected:

  • iOS 5 Mobile Safari, incl iphone and ipad

Correct results

  • Chrome on Android tested, and it successfully fires change event
  • Opera Mobile also fires change event
  • (Android Browser on ICS doesn't have <input type=date> support so its moot there)

How to reproduce:

  1. select a date
  2. click elsewhere to commit the change
  3. change event never fires.

Reduced Example:

Bug Tracker ticket(s):

  • not filed

Workarounds:

  • The blur event fires, so you can bind to that instead. You'll probably want to bind to both and add some fancy logic to cancel out one of them.

paulirish avatar May 11 '12 02:05 paulirish

For the workaround of using both blur and change, you could probably get around it by attaching a single event handler that unbinds when fired once. jQuery has $().one() for that

$("input[type='date']").one("blur change", function(){  
//will only execute once
 });

if you need to have the function execute more than once per DOM element ever, you could re-apply it with a setTimeout, to avoid the dual firing.

yahelc avatar Jun 06 '12 18:06 yahelc

ios select elements don't seem to fire the change event either.

akgrandhi avatar Aug 10 '13 01:08 akgrandhi

Here I am, 7 years later, digging in Stack Overflow and GitHub, because Select elements don't seem to reliability fire onChange on iPad OS version 14. FOURTEEN.

wojtekmaj avatar Oct 07 '20 15:10 wojtekmaj

Ey, 2021 and still existing problems for dropdowns and change event in 2021 on iOS < 13. How the hell can be possible this?

jEstevezRod avatar Jan 27 '21 15:01 jEstevezRod

What's 2021. 2024 still there.

daniluk4000 avatar Jan 11 '24 22:01 daniluk4000