<textarea rows="8" cols="28" onKeyUp="checkWordLen(this,200);"></textarea>
TOTAL WORDS : <span id="word_counter" style="color:#FF0000;">0/200</span>
function checkWordLen(obj,MaxLen)
{
var len = obj.value.split(/[\s]+/);
counter = len.length-1;
document.getElementById('word_counter').innerHTML = counter+"/"+MaxLen;
if(len.length > MaxLen)
{
objvalue = obj.value.split(/[\s]+/);
var newval = '';
for(var m=0; m<MaxLen; m++)
{
newval+=objvalue[m]+' ';
}
obj.value='';
obj.value=newval;
return false;
}
return true;
}

Thanks Vasim,
ReplyDeleteGreat work.
It works perfectly...
Hi Vasim
ReplyDeleteIs there a way you can modify this so it will handle multiple text areas with different max word amounts. Can pay for working script.
Email me: hugsbu@gmail.com
Many thanks
H.