The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
Occurs when the text content of an element is changed through the user interface.
![]() ![]() |
Syntax
| HTML Attribute | <element oninput = "handler(event)"> |
|---|---|
| Event Property | object.oninput = handler; |
| attachEvent Method | object.attachEvent("oninput", handler) |
| addEventListener Method | object.addEventListener("input", handler, useCapture) |
Event information
| Synchronous | No |
|---|---|
| Bubbles | No |
| Cancelable | No |
Event handler parameters
- pEvtObj [in]
-
Type: IHTMLEventObj
Standards information
Remarks
You can use the oninput to detect when the contents of a textArea, input type=text, or input type=password have changed. This event occurs immediately after modification, unlike the onchange event, which occurs when the element loses focus.
To invoke this event, do one of the following:
- Enter some text into a form field.
- Cut, delete, or paste content.
- Navigate to another document.
The pEvtObj parameter is required for the following interfaces:
- HTMLAnchorEvents2
- HTMLAreaEvents2
- HTMLButtonElementEvents2
- HTMLControlElementEvents2
- HTMLDocumentEvents2
- HTMLElementEvents2
- HTMLFormElementEvents2
- HTMLImgEvents2
- HTMLFrameSiteEvents2
- HTMLInputFileElementEvents2
- HTMLInputImageEvents2
- HTMLInputTextElementEvents2
- HTMLLabelEvents2
- HTMLLinkElementEvents2
- HTMLMapEvents2
- HTMLMarqueeElementEvents2
- HTMLObjectElementEvents2
- HTMLOptionButtonElementEvents2
- HTMLScriptEvents2
- HTMLSelectElementEvents2
- HTMLStyleElementEvents2
- HTMLTableEvents2
- HTMLTextContainerEvents2
- HTMLWindowEvents2
- HTMLDocumentEvents4
- HTMLElementEvents4
Examples
The following script queries the event target as the text in a textArea is changed.
<script type="text/javascript">
function handleInput(ev) {
alert(ev.target.value);
}
window.onload = function() {
document.getElementById('myTextArea').addEventListener('input',handleInput,false);
}
</script>
<textarea id="myTextArea">Edit this text.</textarea>
See also
- a
- abbr
- acronym
- address
- applet
- area
- audio
- b
- base
- baseFont
- bdo
- bgSound
- big
- body
- blockQuote
- br
- button
- canvas
- caption
- center
- cite
- code
- col
- colGroup
- comment
- custom
- dd
- del
- dfn
- dir
- div
- dl
- document
- dt
- em
- embed
- fieldSet
- font
- form
- frame
- frameSet
- head
- hn
- hr
- html
- i
- iframe
- img
- input type=button
- input type=checkbox
- input type=file
- input type=hidden
- input type=image
- input type=password
- input type=radio
- input type=reset
- input type=submit
- input type=text
- ins
- isIndex
- kbd
- label
- legend
- li
- link
- listing
- map
- marquee
- media
- menu
- meta
- nextID
- noBR
- noFrames
- noScript
- object
- ol
- optGroup
- option
- p
- param
- plainText
- pre
- q
- rt
- ruby
- s
- samp
- script
- select
- small
- source
- span
- strike
- strong
- style
- sub
- sup
- table
- tBody
- td
- textArea
- tFoot
- th
- tHead
- title
- tr
- tt
- u
- ul
- var
- wbr
- video
- window
- xmp
Send comments about this topic to Microsoft
Build date: 1/23/2013

