Thread Starter
5115
(@5115)
Alright, I found this code:
<script type="text/javascript"><!--
var wordLen = 255; // Maximum word length
function checkWordLen(obj){
var len = obj.value.split(/[\s]+/);
if(len.length > wordLen){
alert("You cannot put more than "+wordLen+" words in this text area.");
obj.oldValue = obj.value!=obj.oldValue?obj.value:obj.oldValue;
obj.value = obj.oldValue?obj.oldValue:"";
return false;
}
return true;
}
//--></script>
and for the textarea:
<textarea rows="15" cols="30" name="t1" onchange="checkWordLen(this);"></textarea>
(I know the pop-up would be annoying but, it would prevent readers posting mile long comments.)
The above code almost works. But, after you hit the submit button WordPress still accepts the comment after getting the notice that you have entered too many words. Could anyone help me implement this code so it is functional with WordPress? Or is there an alternative script I can use?
Thanks in advanced.
Thread Starter
5115
(@5115)
@iainpurdie: Thanks for posting that link! Perfect solution.
There’s also a new plugin that will do the trick for you:
Greg’s Comment Length Limiter
All the best,
Greg
(@5115)
18 years, 1 month ago
Is there a way to limit the amount of words or letters in the text area within the comments section so users don’t post such long comments?