In the system, there is a text box that requires uppercase letters. But the user does not realize it, so he has to control it in the program.
In the webpage, pull a TextBox Control:
Copy codeThe Code is as follows:
<Asp: TextBox ID = "TextBoxSeriesNumber" runat = "server"> </asp: TextBox>
To write a Javascript script, you can use the onkeyup event to instantly convert letters to uppercase letters:
Copy codeThe Code is as follows:
<Script type = "text/javascript">
Window. onload = function (){
Var textBox = document. getElementById ("<% = TextBoxSeriesNumber. ClientID %> ");
TextBox. onkeyup = function (){
This. value = this. value. toUpperCase ();
};
};
</Script>
Demo:
The following content is added:
In the above method, there is a problem: the lower-case letters are displayed first, and then converted to the upper-case letters. When searching for other materials on the Internet, I did not intend to find a better method, that is, using CSS to achieve:
Style = "text-transform: uppercase ;"
The complete application is as follows:
Description of text-transform style attributes: