How to limit the number of characters entered in a text area

后端 未结 6 1367
忘了有多久
忘了有多久 2020-12-10 08:58

Here\'s my attempt at limiting the number of characters entered into a text area:

var limit = 255;
var txt = $(\'textarea[id$=txtPurpose]\');

$(txt).keyup(f         


        
6条回答
  •  鱼传尺愫
    2020-12-10 09:23

    var limit="NO of characters";

    $(this).val( $(this).val().substring(0, limit) );

提交回复
热议问题