Javascript DOM InputEvent data Property

Introduction

Return the input data from a text field:

The data property returns the character that was inserted with the event.

Write something in the text field to trigger a function.

This property is not fully supported, and can change before the final release.

View in separate window

<!DOCTYPE html>
<html>
<body>
<input type="text" id="myInput" oninput="myFunction(event)">
<p>The inserted character: <span id="demo"></span></p>
<script>
function myFunction(event) {// w w  w  . j  a  va 2 s . co  m
  document.getElementById("demo").innerHTML = event.data;
}
</script>
</body>
</html>

The data property returns the character that was inserted with the event.

This property is read-only.

The data property returns a String indicating which character that was inserted.




PreviousNext

Related