Thomas John
Thomas John

Reputation: 1899

jquery word limiter?

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

Answers (1)

jAndy
jAndy

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

Related Questions