I am trying to implement a word counter in textbox. I am using the links below:
<textarea name="myMessage" onkeyup="wordcount(this.value)"></textarea>
<script type=""text/javascript"">
var cnt;
function wordcount(count) {
var words = count.split(/\s/);
cnt = words.length;
var ele = document.getElementById('w_count');
ele.value = cnt;
}
document.write("<input type=text id=w_count size=4 readonly>");
</script>
Word counter is working fine. But my scenario is like as below:
- for word "Most Suitable Match" if user type short form as "MSM" then MSM also shall be counted as 3 words.
- In the same way if there is name of college like "DAV" then it shall also be counted as 3 words.
Please suggest !!