Javascript DOM onkeyup Event via HTML Tag onkeyup attribute

Introduction

This example demonstrates how to assign an "onkeyup" event to an input element.

Press a key inside the text field and release it to set the text to uppercase.

View in separate window

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

<script>
function myFunction() {//from   w ww  .ja  va2  s .c  o  m
  var x = document.getElementById("fname");
  x.value = x.value.toUpperCase();
}
</script>

</body>
</html>
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