Categories
JavaScript Answers

How to change lowercase characters to uppercase using the keyup event with JavaScript?

Spread the love

Sometimes, we want to change lowercase characters to uppercase using the keyup event with JavaScript.

In this article, we’ll look at how to change lowercase characters to uppercase using the keyup event with JavaScript.

How to change lowercase characters to uppercase using the keyup event with JavaScript?

To change lowercase characters to uppercase using the keyup event with JavaScript, we set the value to upper case with toUpperCase.

For instance, we write

const input = document.getElementById("inputID");

input.onkeyup = (e) => {
  e.target.value = e.target.value.toUpperCase();
};

to get the input with getElementById.

Then we set its onkeyup property to convert the input value to upper case with toUpperCase.

We then assign the returned string back to e.target.value to update the string.

Conclusion

To change lowercase characters to uppercase using the keyup event with JavaScript, we set the value to upper case with toUpperCase.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *