Have an account? Sign in
Login  Register  Facebook
This Page is Under Construction! - If You Want To Help Please Send your CV - Advanced Web Core (BETA)
[Edit] jQuery maximum limit textarea
This is a simple HTML page which has a textarea input field and a span which keeps showing the number of characters left as you are typing.
<html>
 <header>
 <script src="jquery.js" type="text/javascript"></script>
 <script src="textcounter.js" type="text/javascript"></script>
 </header>
 <body>
 <textarea class="word_count" rows="5" cols="40"></textarea>
 <br/>
 <span class="counter"></span>
 </body>
 </html>
$(document).ready(function(){
 /**
  * Character Counter for inputs and text areas showing characters left.
  */
 $('.word_count').each(function(){
     //maximum limit of characters allowed.
     var maxlimit = 240;
     // get current number of characters
     var length = $(this).val().length;
     if(length >= maxlimit) {
   $(this).val($(this).val().substring(0, maxlimit));
   length = maxlimit;
  }
     // update count on page load
     $(this).parent().find('.counter').html( (maxlimit - length) + ' characters left');
     // bind on key up event
     $(this).keyup(function(){
  // get new length of characters
  var new_length = $(this).val().length;
  if(new_length >= maxlimit) {
    $(this).val($(this).val().substring(0, maxlimit));
    //update the new length
    new_length = maxlimit;
   }
  // update count
  $(this).parent().find('.counter').html( (maxlimit - new_length) + ' characters left');
     });
 });

});