C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !






Javascript Character Counter


Posted Date: 30 Jul 2008    Resource Type: Code Snippets    Category: Javascript

Posted By: fayaz       Member Level: Gold
Rating:     Points: 5



This javascript code sample helps to show the number of characters remaining to be entered in the textbox.

The example is a html page that contains a textarea control and a text control. The former is used for user input and the other display number of remaining characters that could be enetered. This value is computed dynamically at the client side by the javascript function given below.


<html>

<body>
<script language="JavaScript">
function textCounter(field, countfield, maxlimit)
{

if (field.value.length > maxlimit)
field.value =field.value.substring(0, maxlimit);
else
countfield.value = maxlimit - field.value.length;
}

</script>

<form id="form1" method="post">
<textarea name="message" cols="25" rows="4" wrap="PHYSICAL" id="message" onkeydown="textCounter(this.form.message, this.form.remLen,50);" onkeyup="textCounter(this.form.message, this.form.remLen,50); "></textarea>
<input name="remLen" type="text" id="remLen" value="50" size="3" maxlength="3" readonly />
</form>
</body>
</html>





Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Character counter using Javascript  .  Javascript Character Counter  .  Character Counter in Javascript  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Dynamic menu with HTML,CSS and Javascript
Previous Resource: Word Counter
Return to Discussion Resource Index
Post New Resource
Category: Javascript


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

it support

Contact Us    Privacy Policy    Terms Of Use