Results 1 to 2 of 2

Thread: Max number of words in textareas

  1. #1
    Join Date
    Feb 2009
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Max number of words in textareas

    Hi all. I hope someone can help me.

    I have a script that counts the number of characters and an alert when the total excedes the limit. What I want is to change this to words rather than characters.

    current code:
    [CODE]
    function maxLength(field,maxWords)
    {
    if(field.value.length >= maxWords) {
    event.returnValue=false;
    alert("more than " +maxWords + " words");
    return false;
    }

    }

    function maxLengthPaste(field,maxWords)
    {
    event.returnValue=false;
    if((field.value.length + window.clipboardData.getData("Text").length) > maxWords) {
    alert("more than " +maxWords + " ");
    return false;
    }
    event.returnValue=true;
    }

    [CODE]

    I then add [ICODE] onKeyPress='return maxLength(this,"500");' onpaste='return maxLengthPaste(this,"500");' [ICODE] within the textarea.

    Grafeful if anyone has something similar for words.

    thanks

  2. #2
    Join Date
    Feb 2009
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Does anyone have anything slightly similar to my code above for word count?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •