Introduction: In this article I am going to share how to automatically
change text to upper or lower case while entering text in textbox using jquery.
In previous articles I explained
how to Capitalize first letter, Convert text to uppercase or lowercase while typing using CSS and jQuery to expand or resize multiline textbox on mouse over and mouse out and validate,upload,crop and store image in folder in asp.net using jQuery and jQuery to disable right click on page to protect HTML Source or images from being copied and jQuery to Check Uncheck all items in CheckBoxList on click of Select All CheckBox
Description: Sometimes we want to
restrict the user to enter text in specific case e.g. uppercase or lowercase . There
are multiple ways to achieve this. Here I am sharing the trick using jquery.
Implementation: Let’s create a
demo page for demonstration purpose.
HTML Source
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script
type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script
type="text/javascript">
$(document).ready(function
() {
//
Convert text to Upper Case
$('#<%=txtUpperCase.ClientID%>').keyup(function
() {
this.value = this.value.toUpperCase();
});
//
Convert text to Lower Case
$('#<%=txtLowerCase.ClientID%>').keyup(function
() {
this.value = this.value.toLowerCase();
})
})
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<fieldset
style="height:
80px; width:
345px;">
<legend>Convert text to uppercase or lowercase
while typing</legend>
<table>
<tr>
<td>Text in upper case: </td>
<td>
<asp:TextBox ID="txtUpperCase" runat="server" /></td>
</tr>
<tr>
<td>Text in lower case: </td>
<td>
<asp:TextBox ID="txtLowerCase" runat="server" /></td>
</tr>
</table>
</fieldset>
</div>
</form>
</body>
</html>
Now over to you:
If you have any question about any post, Feel free to ask.You can simply drop a comment below post or contact via Contact Us form. Your feedback and suggestions will be highly appreciated. Also try to leave comments from your account not from the anonymous account so that i can respond to you easily..