Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

character remaining count

Posted on 2014-02-14
1
Medium Priority
?
241 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
1 Comment
 
LVL 21

Accepted Solution

by:
Craig Wagner earned 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

926 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