how to validate textbox with 100 words?

how to validate textbox with 100 words?

i know how to validate the character nut to do with words plz suggest.
below function is use to validate the characters:
  $('#txtCompanyProfile').keyup(function () {
                var maxWords = document.getElementById('<%= hiddenProfileMaxValue.ClientID%>').value;
               var cs = $(this).val().length;
               $('#characters').text(cs);
              
               $('#txtCompanyProfile').keypress(function (e) {
                if (e.which < 0x20) {
                       return;     // Do nothing
                }
               
                   if (this.value.length == maxWords) {
                       e.preventDefault();
                       alert("Only " + maxWords + " characters are allowed.");
                   } else if (this.value.length > maxWords) {
                       // Maximum exceeded
                      
                       this.value = this.value.substring(0, max);
                       
                   }
               });
            });