Enter lowercase letters in the text box to convert to uppercase to implement ideas _ practical tips

Source: Internet
Author: User
Tags lowercase

In the system, there is a text box that requires a capital letter to be entered. But the user unconsciously, had to control in the program.

In the Web page, pull a TextBox control:

Copy Code code as follows:

<asp:textbox id= "Textboxseriesnumber" runat= "Server" ></asp:TextBox>

Write JavaScript scripts, you can use the onkeyup event to instantly convert letters to uppercase letters:
Copy Code code 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 is added at 15:08:
The problem with the above method is to show the lowercase letters first, and then turn to uppercase letters. Find other information on the Internet, and inadvertently sent a better way, is to use CSS to achieve:
Style= "Text-transform:uppercase;"
The full application is as follows:

For a description of the Text-transform style properties:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.