this is the jquery code
var max_count = 200; $(document).ready(function () { var wordCounts = {}; $("#word_count").keyup(function () { var matches = this.value.match(/\b/g); wordCounts[this.id] = matches ? matches.length / 2 : 0; var finalCount = 0; $.each(wordCounts, function (k, v) { finalCount += v; }); var vl = this.value; if (finalCount > max_count) { vl = vl.substring(0, vl.length - 1); this.value = vl; } var countleft = parseInt(max_count - finalCount); $('#display_count').html(finalCount); $('#count_left').html(countleft); am_cal(finalCount); }).keyup(); }); The work of this code is to count the number of words and limit them going up 200.
When we type in the textarea it works fine, and it counts and when it reaches 200 it does not allow to write more, but when i copy paste the code, it keeps going above 200, how can i correct this?
here is the fiddle
Thanks in advance
});at the end and the functionam_calis missing});