Counting and limiting words in a textarea

前端 未结 6 1701
情歌与酒
情歌与酒 2020-11-28 13:35

I managed to make this little jquery function to count the number of words entered in textarea field.

here is the fiddle

and here is the code:

JQUERY

6条回答
  •  攒了一身酷
    2020-11-28 13:57

    Adding a simple if condition will solve your problem.

    $.each(wordCounts, function(k, v) {
        if(finalCount <= 200) {
            //Todos
        }
        else {
          return false;  //prevent keyup event
        }
     });
    

提交回复
热议问题