tags:

views:

333

answers:

2

I want to limit the number of words a person can enter in a text field. How can I track the number of words (by using a second field) in that field as each word is entered?

+1  A: 

use this js (using jquery):

$('#newKeywords').bind('change', function() {

   $('#wordsLong').text($('#newKeywords').val().split(' ').length + 1);

});

and this html:

<textarea id="newKeywords"></textarea>
<div>The text consists of <span id="wordsLong"></span> keywords.</div>
henchman