jquery - How to limit the size of an HTML textarea with JavaScript? -


Is there a code to limit characters in any one text field and display the character count?

I need something like Twitter Status Input and I can not find anything online if there is nothing, then I will probably talk to a jQuery plugin or at least open source.

Thank you!

Take a look at this page:

  & lt; Script language = "javascript" & gt; Function border (text, border, infodiv) {var text = $ ('#' + textid) .val (); Var TextLanguage = Text Long; If (Text Lang & gt; range) {$ ('#' + infodiv) .html ('You can not type more' + limit + 'characters!); $ ('#' + Textid) .val (text.substr (0, border)); return false; } And {$ ('#' + Infographic) .html ('You have' + (Segment - TextLabel) + 'characters remaining.'); Return true; }} & Lt; / Script & gt;  

Then tie the function in your texture key up event. To do this in the event of this kind of JQuery:

  $ (function () {$ ('# comment') .keyp (function () {limitChars ('comment', 20 , 'Charlimitinfo');})});  

Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -