Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

limit BuddyPress status update box

By: a guest on Jun 10th, 2011  |  syntax: None  |  size: 0.79 KB  |  views: 173  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ;(function(jQuery){
  2.         jQuery.fn.clearTextLimit = function() {
  3.                 return this.each(function() {
  4.                         this.onkeydown = this.onkeyup = null;
  5.                 });
  6.         };
  7.         jQuery.fn.textLimit = function( limit , callback ) {
  8.                 if ( typeof callback !== 'function' ) var callback = function() {};
  9.                 return this.each(function() {
  10.                         this.limit = limit;
  11.                         this.callback = callback;
  12.                         this.onkeydown = this.onkeyup = function() {
  13.                                 this.value = this.value.substr(0,this.limit);
  14.                                 this.reached = this.limit - this.value.length;
  15.                                 this.reached = ( this.reached == 0 ) ? true : false;
  16.                                 return this.callback( this.value.length, this.limit, this.reached );
  17.                         }
  18.                 });
  19.         };
  20. })(jQuery);
  21.        
  22.          jQuery('textarea').textLimit(100,function( length, limit ){
  23.         jQuery(this).next().text( limit - length );
  24.     });