Not a Member Yet,
Click here to Register

ID: 124
Viewed: 3810
Added: Apr 26, 2002
Version:
Snippet uploaded by: snippet
Written By: The JavaScript Source
Demo: Sorry, no demo



User Rated at: 0 Stars
Rate This:

Thank you for your vote. Please wait...

It appears you already voted for this snippet

It appears your vote value was empty

This neat little script will count the characters in a textarea and will not let you add more text. Browsers: IE5+ NS6+ will not work in NS4.x

<!---Head--->
<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Ronnie T. Moore -->
<!-- Web Site: The JavaScript Source -->

<!-- Dynamic 'fix' by: Nannette Thacker -->
<!-- Web Site: http://www.shiningstar.net -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else
countfield.value = maxlimit - field.value.length;
}
// End -->
</script>

<!---Body--->


 <form name=form1>
<textarea name=content cols=70 rows=18 onKeyDown="textCounter(this.form.content,this.form.remLen,4000);"
onKeyUp="textCounter(this.form.content,this.form.remLen,4000);"
onFocus="textCounter(this.form.content,this.form.remLen,4000);">
</textarea>
<br><br>
<input readonly type=text name=remLen size=4 maxlength=4 value="4000" style="border: 1px;"> characters left</font>
</form>


No Comments to show

Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.


Replying to a Comment...


Adding your comment. Please wait...

Thanks for adding your comment!. After further review it will be added.

There was a problem adding your comment. Please try again.

Please complete all the fields in the form before sending.

© 2002 - 2024 snippetlibrary.com All Rights Reserved. Conditions
Do NOT follow this link or you will be banned from the site!