Solved

character remaining count

Posted on 2014-02-14
1
237 Views
Last Modified: 2014-03-10
I want to display character remaining count when a user start typing. lblcommentscount is displayed 512 when txtbox is empty. How can I prevent this? Instead it should be displayed only when a user start typing.




<script type="text/javascript">
  
     function countCharacters(textbox, label, maxcount) {
        var count = parseInt(document.getElementById(textbox).value.length);
        document.getElementById(label).innerHTML = maxcount - count;
    }


 

 txtcomments.Attributes.Add("onKeyUp", String.Format("countCharacters('{0}','{1}', 512) ", txtcomments.ClientID, lblcommentscount.ClientID))

Open in new window

0
Comment
Question by:VBdotnet2005
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 21

Accepted Solution

by:
Craig Wagner earned 500 total points
ID: 39859983
Make the element not visible on the page and on each keystroke make it visible. Alternatively you could make it visible when the textbox gets focus, but that isn't exactly the requirement you specified.
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question