The onchange attribute is an event-handler attribute for form controls such as <input>, <select>, and <textarea>. It runs JavaScript when the user commits a change to the control’s value.
Unlike oninput (often every keystroke), change waits until the change is committed — for example choosing an option, toggling a checkbox, or leaving a text field after editing.
Baseline · Widely available.
Not deprecated and not experimental. The change event is stable across modern browsers since about July 2015.
Prefer addEventListener in apps.
Inline onchange is fine for learning. Production code usually uses el.addEventListener("change", handler) so logic stays in script and multiple listeners are easy.
Syntax
HTML Syntax
syntax.html
<input|select|textarea onchange="script">
script is JavaScript that runs when change fires. Equivalent JS: el.onchange = handler or el.addEventListener("change", handler).
Values
Attribute Values
The attribute value is always a script. When it runs depends on the control:
Value / control
Description
Try it
script
Any JavaScript run when the user commits a value change
input updates on each edit — good for live filters.
change updates when the value is committed (for text, often on blur).
Same control, different jobs — pick the event that matches your UX.
addEventListener keeps both handlers clear and out of the markup.
Edge Cases & Pitfalls
Most confusion is timing: students expect every keystroke, or forget that script-set values may not fire change.
timing
Text waits for blur
For typing controls, change often fires only after focus leaves. Use oninput for per-keystroke reactions.
radio
Radio fires when checked
A radio fires change when it becomes checked — not when another radio in the group unchecks it.
script
Setting .value in JS
Changing a control’s value with script usually does not fire change. Dispatch an event yourself if your UI needs it.
vs blur
Not the same as onblur
onblur runs whenever focus leaves. onchange runs only if the value actually changed (for that commit).
property
.onchange = replaces listeners
Assigning the IDL property overwrites a previous assignment. Prefer addEventListener for multiple handlers.
Compatibility
Browser Support
onchange 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
onchange
Widely available since about July 2015. Chrome, Firefox, Safari, Edge, and Opera support the change event on common form controls.
98%Global support (approx.)
Google Chrome1+
Full support
Mozilla Firefox1+
Full support
Apple Safari1+
Full support
Microsoft Edge12+
Full support
Opera9+
Full support
Samsung InternetModern · Full
Full support
Internet ExplorerAll
Supported
onchangeWidely supported
Bottom line: Safe to use for committed form-value reactions. Prefer addEventListener in production, and use oninput when you need live updates while typing.
Remember
Key Takeaways
Role: run script when a form control’s value is committed.
vs oninput: live edits vs committed change.
Timing: select/checkbox soon; text often on blur after edit.
Apps: prefer addEventListener("change", …).
One line:onchange reacts when the user commits a new value — not on every keystroke.
Frequently Asked Questions
It is an event-handler attribute for form controls such as input, select, and textarea. When the user commits a change to the control’s value, the change event fires and the JavaScript in onchange runs.
Primarily input, select, and textarea. Timing depends on the control: checkboxes and radios fire on toggle/select; text fields often fire after the value changes and the control loses focus.
oninput usually fires on every edit (each keystroke). onchange fires when the change is committed — for text, often on blur; for select, when an option is chosen.
Usually not for every key. For text, search, email, and similar types (and textarea), change typically fires after the value has changed and the control loses focus.
Both work. For learning, onchange in HTML is fine. In production code, prefer element.addEventListener("change", handler) so you can attach multiple listeners and keep script out of markup.
No. The change event and onchange handler are standard HTML features and Baseline widely available since about July 2015.