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

jQuery Limit Number of Characters in Textarea (Textbox) Even Copy Paste Text

Jul 30, 2014

here I will explain how to use
jQuery to limit number of characters in textarea(textbox) even copy and paste text or  jQuery restrict textbox(textarea) length even copy and paste text in textbox with example.


In previous post I explained
jQuery Tag cloud example in, jQuery show datatable on aspx page in, send html page as mail body in, how to send mail with attachment in and many more articles related to jQuery,, c# and Now I will explain how to how to restrict textbox(textarea) length even copy and paste text in textbox with example in jQuery

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

<html xmlns="">
<title>jQuery Limit Number of Characters in a TextArea</title>
<script type="text/javascript" src=""></script>
<script type='text/javascript'>
$(function() {
$('#textarea1').keyup(function() {
var desc = $('#textarea1').val();
var len = desc.length;
if (desc.length >= 150) {
this.value = this.value.substring(0, 150);
$('#spntxt').text(150 - len + ' Characters Left');
<textarea id="textarea1" cols="20" rows="8"></textarea><br/>
<span id="spntxt"> 150 Characters left</span>
Live Demo

To check live demo try to copy and paste text in textarea it will restrict to 150 characters

Enter Text:

150 Characters left

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

Get the latest,, 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


Anonymous said...

If I Enter the character in text area wide out of range 150, It allows the character. but only shows the message for (0 Characters Left )

Give your Valuable Comments

Other Related Posts

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