Here is a quick example that worked in IE6:
<html>
<head>
<title>Jump cursor to next Text Box</title>
<SCRIPT LANGUAGE="JavaScript">
NS6=document.getElementById&&!document.all? 1:0;
function Maxwords(fldobj,e,maxwords)
{
if (NS6)
{var keycode = e.which} // capture key pressed for Netscape
else
{var keycode = event.keyCode} // capture key pressed for IE
// alert(keycode)
words=new Array()
words=fldobj.value.split(" ")
if(words.length>maxwords&&keycode!="8") //if the number of words is greater than the max
{return false} // and the key is not a backspace then do not allow
} // anymore words. This was don because NS would not allow the
// the backspace when max words was reached.
</SCRIPT>
</head>
<body>
<CENTER>
<FORM NAME="myform">
<textarea name="txt1" rows="10" cols="50" onKeyPress="return Maxwords(this,20)"></textarea>
</FORM>
</CENTER>
</body>
</html>
I modified the script because it was not working correctly with Mozilla browsers.