input | oninput event

This topic has not yet been rated - Rate this topic

Occurs when the text content of an element is changed through the user interface.

HTML5 A vocabulary and associated APIs for HTML and XHTML

Syntax

HTML Attribute <element oninput = "handler(event)">
Event Property object.oninput = handler;
addEventListener Method object.addEventListener("input", handler, useCapture)

Event information

SynchronousNo
BubblesNo
CancelableNo

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.

Examples

The following script queries the event target as the text in a textArea is changed.


<script type="text/javascript">
function handleInput(ev) {
    console.log(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
address
area
audio
b
base
bdo
body
blockQuote
br
button
canvas
caption
cite
code
col
colGroup
comment
custom
dd
del
div
dl
document
dt
em
embed
fieldSet
form
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
kbd
label
legend
li
link
map
media
meta
object
ol
optGroup
option
p
param
pre
q
rt
ruby
s
samp
script
select
small
source
span
strong
style
sub
sup
table
tBody
td
textArea
tFoot
th
tHead
title
tr
u
ul
var
video
window

 

 

Send comments about this topic to Microsoft

Build date: 11/29/2012

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.