Reputation: 1899
Hello I am looking for a jquery (or javascript) based word limiter ? searched on web but only char. limiters
please help
Thanks a lot
Upvotes: 1
Views: 402
Reputation: 236022
Sounds like:
$('input').bind('keydown', function() {
var words = $(this).val().split(/\s/);
if( words.length > 3 ) {
alert('limited to three words');
return false;
}
});
example: http://www.jsfiddle.net/4yUqL/50/
Upvotes: 4