addEventListener("keyup", myFunction); - Javascript DOM Event

Javascript examples for DOM Event:addEventListener

Description

The onkeyup event occurs when the user releases a key.

Summary

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

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

Enter your name: <input type="text" id="fname">

<script>
document.getElementById("fname").addEventListener("keyup", myFunction);

function myFunction() {//ww w.  ja v  a2s  . c om
    var x = document.getElementById("fname");
    x.value = x.value.toUpperCase();
}
</script>

</body>
</html>

Related Tutorials