lunes, 25 de noviembre de 2013

maxLength - How to limit the number of char in a textarea field with Jquery


maxLength Jquery

By http://jquery-manual.blogspot.com


Download on GITHUB

maxLength is a Jquery function that allows you to limit the number of char in a textarea field.

maxLength has two parameters:
  • limit : To specify the maximum number of characters.
  • options(opcional) : Modifies the following two options:
    • showNumber : Element. To indicate the element that displays the counter.
    • revert : true | false. Default true. The order will counter, high to low (true) or low to high (false).
LIMIT:
Jquery code:
$(function(){
$("#textarea").maxLength(50, {
showNumber: "#limit", 
revert: true
});
});

HTML code:
<div>LIMIT: <span id="limit"></span></div>
<textarea id="textarea" cols="30" rows="15"></textarea>




No hay comentarios: