the oninput event is fired.
to try:
<!doctype html> <html> <head> <meta charset="utf-8"> <title>title</title> </head> <body> <form method="get" id="" action=""> <input type="text" name="name" oninput="alert('oninput')"/> <input type="submit" value="done"/> </form> </body> </html>
difference between oninput, onpropertychange, onchange:
onchange only starts when
a) property changed using the user interface
b), and the element has lost focus
onpropertychange is triggered when a property changes. but it is only IE
oninput
oninput is a version of W3C onpropertychange. IE9 begins to carry this event.
oninput only starts when the value of an element changes.
so if you want flexibility in all browsers
IE <9 uses onpropertychange
IE> 9 and other use of broweser oninput
if you use jQuery you can bind two events that use the same hander
$(function($) { //the same handler function oninput(e){ //do sth } $("#ipt").on("input", function(e){ console.log("trigger by oninput"); oninput(e); }) $("#ipt").on("propertychange", function(e) { console.log("trigger by propertychange"); oninput(e); }) })
demo at http://output.jsbin.com/salekaconi
source share