Google Javascript character counter

Sep 13, 2010

Javascript character counter

This is a simple javascript code that count the number of character in the text area.

[Code]-Html
<form method="POST">

<textarea class="textarea-style" name="charcount"></textarea>
<div class="clear"></div>

<input onclick="countit(this)" type="button" value="Calculate Characters number" /> <input name="displaycount" size="20" type="text" />
<div class="clear"></div>
<div class="javascript-ex">
This free script provided by
<a href="http://w3onlinesource.blogspot.com/">w3onlinesource.blogspot.com</a></div>

</form>
[Code]-Javascript
<script language="JavaScript">
function countit(what){
//w3onlinesource.blogspot.com
formcontent=what.form.charcount.value
what.form.displaycount.value=formcontent.length
}
</script>
[Code]-CSS
<style type="text/css">
.textarea-style
{
height: 200px;
width: 350px;
word-wrap: break-word;
padding:5px 5px 5px 5px;
margin:5px 5px 5px 5px;"
}
.javascript-ex
{
margin:10px 5px 5px 5px 5px;
text-align:left;

}
</style>






This free script provided by
w3onlinesource.blogspot.com










No comments:

Post a Comment