The oninput attribute is an event-handler attribute. It runs JavaScript when the input event fires — the control’s value changed from a user action (typing, pasting, checking a box, dragging a range, choosing an option, and similar).
Common on <input>, <textarea>, and <select>. Related: onchange (often when the edit is committed), onkeyup, and oninvalid.
Baseline · Widely available.
Not deprecated and not experimental. For text controls, input fires while editing; change usually waits until the value is committed (for example on blur). The event bubbles.
Discouraged as inline HTML.
MDN discourages HTML event handler attributes. Prefer el.addEventListener("input", handler) in production; use inline oninput for quick demos and learning.
Syntax
HTML Syntax
syntax.html
<input|textarea|select oninput="script">
script is JavaScript that runs on each user-driven value change. Equivalent JS: el.oninput = handler or el.addEventListener("input", handler).
Values
Attribute Values
The attribute value is always a script. Common patterns:
oninput runs continuously during the drag — good for live labels.
this.value is the current number as a string.
Compare with onchange — change often fires when the user finishes the interaction.
Edge Cases & Pitfalls
Most “input never fired” bugs are setting value in script and expecting the event.
script
Programmatic value = no input
Per MDN, assigning el.value = "…" (or changing options in ways that only update via script) does not fire input. Call your update function yourself after scripted changes.
change
Not the same as change
Use input for live feedback. Use onchange when you care that the user finished editing (common for text: fire on blur after a change).
reset
Form reset
Resetting a form fires reset, not input. Re-sync labels/counters from a reset handler if needed.
checkbox
Checkbox / radio history
Modern browsers fire input when toggling checkbox/radio, but older behavior varied. Prefer also listening to change if you must support very old clients.
perf
Fires often while typing
Heavy work (network search, big DOM updates) on every keystroke can lag. Debounce expensive handlers; keep simple UI updates immediate.
Compatibility
Browser Support
oninput is an HTML event-handler attribute for form controls in the browser. It is not a Node.js, Deno, or Bun API.
✓ Baseline · Widely available
oninput
Baseline widely available. Chrome, Firefox, Safari, Edge, and Opera support input on text, textarea, select, and range controls.
97%Global support (approx.)
Google ChromeAll modern
Full support
Mozilla FirefoxAll modern
Full support
Apple SafariAll modern
Full support
Microsoft EdgeAll modern
Full support
OperaAll modern
Full support
Samsung InternetModern
Full support
Internet Explorer9+
Partial / quirks
oninputWidely supported
Bottom line: Safe to use for live form UX. Prefer addEventListener('input') in apps, and remember scripted value changes do not fire input.
Remember
Key Takeaways
Role: value changed from a user action — live.
vs change:input while editing; change when committed.
Bubbles — good for form-level delegation.
Scripted value does not fire input.
One line:oninput means the user just changed the value — react immediately, or use onchange when they are done.
Frequently Asked Questions
It is an event-handler attribute. When the value of an input, textarea, or select changes from a user action (typing, pasting, moving a range, etc.), the input event fires and the JavaScript in oninput runs.
Primarily input, textarea, and select. It also applies to contenteditable hosts. Put the handler on the control whose value is changing.
For text fields, oninput fires on every edit while typing. onchange typically fires when the edit is committed — often when the control loses focus after the value changed.
No. Per MDN, assigning element.value (or similar programmatic changes) does not fire input. Only user-initiated changes (including many autofill cases) are expected to.
Yes. You can listen on a parent form with addEventListener('input', handler) for event delegation.
No. The input event and oninput handler are standard and Baseline widely available. Inline HTML handlers are discouraged in production in favor of addEventListener.