codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  JavaScript Word Counter  baazil1 at 13:40 on Friday, December 28, 2007
 

Here is the code that I found online to count the words a user has remaining in a textarea.


// Word Count
var submitcount=0;
function checkSubmit() {
if (submitcount == 0)
{
submitcount++;
document.Surv.submit();
}
}
function wordCounter(field, countfield, maxlimit) {
wordcounter=0;
for (x=0;x<field.value.length;x++) {
if (field.value.charAt(x) == " " && field.value.charAt(x-1)!= " ") {wordcounter++} // Counts the spaces while ignoring double spaces, usually one in between each word.
if (wordcounter > 250) {field.value = field.value.substring(0, x);}
else {countfield.value = maxlimit - wordcounter;}
}
}
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit)
{field.value = field.value.substring(0, maxlimit);}
else
{countfield.value = maxlimit - field.value.length;}
}


Here are the textarea fields...


<textarea name="Q3367" cols="50" rows="4" wrap="hard" onKeyDown="wordCounter(this.form.Q3367,this.form.remLen,250);" onKeyUp="wordCounter(this.form.Q3367,this.form.remLen,250);">

  Re: JavaScript Word Counter  benben at 06:29 on Saturday, May 21, 2011
 


Replica Burberry men watches Online
Replica Burberry Chronograph men watches Online
Replica Burberry men watches Online
Replica Burberry Chronograph champagne men watches Online
Replica Cartier Ballon Bleu Ladie watches Online
Replica Cartier Ballon Bleu Ladie watches Online
Replica Cartier Ballon Bleu Ladie watches Online
Replica Cartier Ballon Bleu Ladie watches Online
Replica Cartier Ballon Bleu Ladie watches Online
Replica Cartier Ballon Bleu Ladie watches Online








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Lucene Revolution --Training Classes
•  Scraps
•  Error on conditional webpage
•  Re: horizontal scroll bar for drop down list box
•  Re: JavaScript Word Counter
•  Re: change embed src using javascript
•  Re: DateDiff in C++
•  Re: setcapture in firefox
•  Re: C++ Inheritance Polymorphism


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2011