oninput Event
Example
Call a function when a user writes something in an <input> field:
More examples below.
Description
Theoninput event occurs whenan element gets input.
Theoninput event occurs when the value of an <input> or <textarea> or <select> element is changed.
Note
Theoninput event is similar to theonchange event.
The difference is that theoninput event occurs immediately after the content has been changed, whileonchange occurs when the element loses focus.
Syntax
In #"tryit.asp?filename=tryjsref_oninput_dom">Try it Yourself »
In JavaScript, using the addEventListener() method:
Technical Details
| Bubbles: | Yes |
|---|---|
| Cancelable: | No |
| Event type: | Event,InputEvent |
| HTML tags: | <input> and <textarea> |
| DOM Version: | Level 3 Input Events |
More Examples
Example
Range slider - how to dynamically update slider value:
Browser Support
oninput is a DOM Level 3 (2004) feature.
It is fully supported in all modern browsers:
| Chrome | Edge | Firefox | Safari | Opera | IE |
| Yes | Yes | Yes | Yes | Yes | 11 |

