InputField Word Count?

Hey all,
I’ve been working with this code for character counting in a field for a while:

<script language = "Javascript">
function taLimit() {
 var taObj=event.srcElement;
 if (taObj.value.length==taObj.maxLength*1) return false;
function taCount(visCnt) { 
 var taObj=event.srcElement;
 if (taObj.value.length>taObj.maxLength*1) taObj.value=taObj.value.substring(0,taObj.maxLength*1);
 if (visCnt) visCnt.innerText=taObj.maxLength-taObj.value.length;

It works very well, but I wondered if anybody might be able to give me some tips as to how I might modify it to count words, not characters? Thanks in advance!!