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>
|