Horje

How to Execute a JavaScript when a user releases a key - HTML onkeyup Attribute

A function is triggered when the user releases a key in the input field. The function transforms the character to upper case.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<p>A function is triggered when the user releases a key in the input field. The function transforms the character to upper case.</p>
Enter your name: <input type="text" id="fname" onkeyup="myFunction()">

<script>
function myFunction() {
  let x = document.getElementById("fname");
  x.value = x.value.toUpperCase();
}
</script>

</body>
</html>

Output should be:

How to Execute a JavaScript when a user releases a key - HTML onkeyup Attribute




Type:
html
Category:
Web Tutorial
Sub Category:
HTML Attribute
Uploaded by:
Admin