Device-Bugs
Device-Bugs copied to clipboard
iOS5 datepickers don't fire onchange
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:
- select a date
- click elsewhere to commit the change
- 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.
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.
ios select elements don't seem to fire the change event either.
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.
Ey, 2021 and still existing problems for dropdowns and change event in 2021 on iOS < 13. How the hell can be possible this?
What's 2021. 2024 still there.