-
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
-
-
Does anyone have anything slightly similar to my code above for word count?
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks