Automatic conversion of uppercase and lowercase letters in the input box

There are two ways to automatically convert lowercase letters into uppercase letters in the input input box

1. Use the js onkeyup event to instantly convert letters to uppercase letters:

add input in html

 <input type="text" id="txt1" value="" onkeyup="toUpperCase(this)"/>

js write function

1 function toUpperCase(obj)
2  {
3  obj.value = obj.value.toUpperCase()
4  }

Although this method works, it will be disturbed when inputting Chinese characters. There is a better method.

add css

 <input type="text" id="txt1" value="" style="text-transform:uppercase"/>

Transform text in different elements:

h1 {text-transform:uppercase;}
h2 {text-transform:capitalize;}
p {text-transform:lowercase;}

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325312563&siteId=291194637