Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

jQuery Set Maxlength for Multiline Textbox in Asp.net

Dec 19, 2013
Introduction

Here I will explain how to set maxlength for multiline textbox in asp.net using
jQuery or set of maxlength for asp.net multiline textbox in jQuery.
                                                                                   
Description:
  
In previous articles I explained
jQuery disable right click on images, jQuery expand textbox on focus , jQuery slideup slidedown slidetoggle example, jQuery fadein or fadeout example, jQuery create rounded corners for textbox, jQuery show time in webpage and many articles relating to JQuery. Now I will explain how to set maxlength for multiline textbox in asp.net using jQuery.

To implement this we need to write the code like as shown below


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQuery set maxlength for multiline textbox in asp.net</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js">
</script>
<script type="text/javascript">
$(function() {
$('#txtdesc').keypress(function(e) {
var txt = $(this).val();
if (txt.length > 50) {
e.preventDefault();
}
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<table>
<tr>
<td>
<b>Enter Text:</b>
</td>
<td>
<asp:TextBox ID="txtdesc" TextMode="MultiLine" runat="server" ></asp:TextBox>
</td>
</tr>
</table>
</form>
</body>
</html>

Live Demo

Enter Text:

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

7 comments :

vj said...

It is useful...thanks

Anonymous said...

great!!!!!!!!

Anonymous said...

This wont work in IE if you copy paste the data

Anonymous said...

set property onpaste="return false" for text box

Unknown said...

Its Good. But After Writing Data in TextBox we can not select writing data means Ctrl+A Not Appear. So Please Gime Solution for that.

Unknown said...

it's not working sometime in asp textboxs

Anonymous said...

its not working in case of cut and paste.

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.