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 Maximum Length to Textarea or jQuery Check Textarea Maxlength

Dec 18, 2013
Introduction

Here I will explain how to set maximum length of textarea in
jQuery or check maximum length of textarea 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 check maxmimum length of textarea in 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 Check count of textarea</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js">
</script>
<script type="text/javascript">
$(function() {
$('#btnCheck').click(function() {
var txt = $('#txtdesc').val();
if (txt.length > 50) {
alert('Please enter less than 50 characters')
}
});
})
</script>
</head>
<body>
<div>
<table>
<tr>
<td>
<b>Enter Text:</b>
</td>
<td>
<textarea cols="20" id="txtdesc" rows="2" ></textarea>
</td>
</tr>
<tr>
<td></td>
<td> <input type="button" id="btnCheck" value="Check Length" /> </td>
</tr>
</table>
</div>
</body>
</html>

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

2 comments :

Anonymous said...

great man!!!!!!

Unknown said...

This is very basic right?, instead of if this we can achieve throw textbox keypress event that would be professional manner, :) suggestion

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.