How To Change All Input Values Into Uppercase Using jQuery

Description: In this post, we will learn about how to uppercase all the characters of the input box and retrieve all text as uppercase using jQuery. For this demo, first we need to add one input box and create a jQuery keyup event for the input box than we have to use the toUpperCase function for converting input box value from lower case to upper case, than assign this converted text into the input box. Let's start coding.

First, we need to add the below js for accessing the jQuery functions

  1. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> 
HTML Code
  1. <div>  
  2.     <asp:TextBox runat="server" ID="txt1" CssClass="upperClass" />  
  3.     <button id="btn" onclick="GetData()">Get</button>  
  4.     <asp:Button runat="server" ID="bvtmn" Text="get" OnClick="bvtmn_Click" Visible="false" />  
  5. </div> 
Javascript Code
  1. <script>  
  2.     $(document).ready(function () {  
  3.         $("input[type=text]").keyup(function () {  
  4.             $(this).val($(this).val().toUpperCase());  
  5.         });  
  6.     });  
  7.   
  8.     function GetData() {  
  9.         alert($("#txt1").val());  
  10.     }  
  11. </script> 

Description of the above code: First we type text in the textbox and this textbox keyup event makes all characters uppercase assigns them to the textbox. After that we click on Button, which displays an alert with uppercase letter text.

See the below output,

Uppercase letter using jquery