The error I am getting is index.html:145 Uncaught ReferenceError: countWord is not defined at HTMLTextAreaElement.onkeyup
Adding my code snippet below. I am new to all of this still, js to be specific.
<form class="contact-form" onsubmit="sendEmail(); reset(); return false;">
<h3>Get In Touch!</h3>
<input type="text" id="name" placeholder="Name *" required>
<input type="email" id="email" placeholder="Email *" required>
<input type="number" id="phone" placeholder="Phone Number (Optional)" >
<textarea id="txt" onkeyup="countWord()" onpaste="countWord()" rows="4" placeholder="Message..."></textarea>
<div class="row mt-3">
<div class="col">
Word Count: <span id="wordCount">0</span>
</div>
</div>
<button id="clearBtn" type="submit">Send message</button>
</form>
</section>
const textField = document.getElementById("txt");
const wordCount = document.getElementById("wordCount");
const clearBtn = document.getElementById("clearBtn");
function countWord(){
let text = textField.value;
text=text.trim();
let words = text.split(" ");
wordCount.innerText = words.length;
} ```
>Solution :
You are missing tags. It should look like
<script>
function countWord(){
let text = textField.value;
text=text.trim();
let words = text.split(" ");
wordCount.innerText = words.length;
}
</script>