textarea限制輸入的字數

​<td colspan="3">
<textarea style="width:60%;" name="strContent" id="strContent" maxlength="2000" class="committee-form-text" data-rule-required="true" data-msg-required="請輸入公務內容"></textarea>
<p><span id="text1">1000</span>/1000</p>
</td>
/*字數限制*/
 $("#strContent").on("input propertychange", function () {
var $this = $(this),
 _val = $this.val(),
 count = "";
if (_val.length > 1000) {
$this.val(_val.substring(0, 1000));
 }
count = 1000 - $this.val().length;
 $("#text1").text(count);
 });

view設置readonly

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章