Code Simplified – Viral Sarvaiya

Code Simplified – Viral Sarvaiya, Web Developer Friends, dot net Developer, Sql Server Developer

Text Box Characters Counter

Posted by Viral Sarvaiya on March 13, 2009

Here’s another way around for you

<script type=”text/javascript” language=”javascript”>

function validatelimit(obj, maxchar)

if( obj = this;

var remaningChar = maxchar – obj.value.length;
document.getElementById(’<%= Label1.ClientID %>’).innerHTML = remaningChar;

if( remaningChar <= 0)
obj.value = obj.value.substring(maxchar,0);
return false;

{return true;}



<asp:TextBox ID=”TextBox1″ runat=”server” TextMode=”MultiLine” onkeyup=”return validatelimit(this,500)” Height=”400px”></asp:TextBox>
<asp:Label ID=”Label1″ runat=”server” Text=”500″></asp:Label>


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: