Hi makenzi.exc,
Split the value of TextArea using the space and using the loop count the no of words.
Note: Ignore the empty values while counting.
Refer below example.
HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style type="text/css">
body { font-family: Arial; font-size: 10pt; }
</style>
</head>
<body>
<textarea id="txtDetails" rows="4" cols="20"></textarea>
<br />
<input type="button" value="Count Words" onclick="CountWord()" />
<br /><br />
<span id="lblMessage"></span>
<script type="text/javascript">
function CountWord() {
var contents = document.getElementById("txtDetails").value.trim();
var wordsCount = 0;
for (var i = 0; i < contents.split(" ").length; i++) {
if (contents.split(" ")[i] != "") {
wordsCount = wordsCount + 1;
}
}
document.getElementById("lblMessage").innerHTML = "Word count: " + wordsCount + ".";
};
</script>
</body>
</html>
Demo
Screenshot

Downloads
Download Sample