CODEDIGEST
Home » CodeDigest
Search
 

Technologies
 

Convert Text in TextBox to LowerCase and UpperCase When User Typing Using Javascript
Submitted By Satheesh Babu B
On 11/30/2008 7:54:54 PM
Tags: CodeDigest,JavaScript  

Convert Text in TextBox to LowerCase and UpperCase When User Typing Using Javascript

 

There are scenarios where we should allows users to type in only upper case characters or a lower case characters in a textbox. It will be good if we automatically do this conversion when the user types in using Javascript.

 

The below Javascript function will help us to do that.

 

 

<script language="javascript">

    function ToUpper(ctrl)

    {  

    var t = ctrl.value;

    ctrl.value = t.toUpperCase();

    }

    function ToLower(ctrl)

    {  

    var t = ctrl.value;

    ctrl.value = t.toLowerCase();

    }

    </script>

 

<asp:TextBox ID="txtName" onkeyup="ToUpper(this)" runat="server"></asp:TextBox>

<asp:TextBox ID="TextBox1" onkeyup="ToLower(this)" runat="server"></asp:TextBox>

Do you have a working code that can be used by anyone? Submit it here. It may help someone in the community!!

Recent Codes
  • View All Codes..