Javascript DOM onkeyup Event

Introduction

Execute a JavaScript when a user releases a key:

A function is triggered when the user releases a key in the input field.

The function transforms the character to upper case.</p>

View in separate window

<!DOCTYPE html>
<html>
<body>
Enter your name: <input type="text" id="fname" onkeyup="myFunction()">

<script>
function myFunction() {// w ww  .  j av  a2 s .c  om
  var x = document.getElementById("fname");
  x.value = x.value.toUpperCase();
}
</script>

</body>
</html>

The onkeyup event occurs when the user releases a key on the keyboard.

Bubbles:
Cancelable:
Event type:
Supported HTML tags:












Yes
Yes
KeyboardEvent
All HTML elements,
EXCEPT:
<base>,
<bdo>,
<br>,
<head>,
<html>,
<iframe>,
<meta>,
<param>,
<script>,
<style>, and
<title>



PreviousNext

Related