Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Event to detect change of an HTML5 number control in Webkit/Chrome?

HTML5 gives us some new input elements to play with, such as <input type=number>. This renders (in Chrome) as a textbox with two cycle buttons inside the textbox, for incrementing and decrementing the numeric value inside the box.

For a personal hobby project, I'm using this control. However, I'm stuck with one issue:

Is there a way to detect the value being changed using a javascript event? I had expected the onChange event to fire, but no such luck. Also, onClick only triggers when the textbox content is clicked, not when the cycle buttons are clicked.

Any ideas? (apart from: hey, it's HTML5 Forms, don't expect anything to work yet!)

Edit: As mikerobi points out below, the onChange event does fire as soon as the element loses focus. Still not quite what I'm looking for, so other comments and suggestions are welcome!

like image 284
kander Avatar asked Oct 30 '10 21:10

kander


1 Answers

Result of the bugreport: Won't Fix, because the input event is fired when those buttons are pressed. It's part of the HTML5 spec. So problem solved, thanks to mikerobi's sugestion to file the report.

like image 94
kander Avatar answered Oct 05 '22 21:10

kander