tags:

views:

30

answers:

1

Is the JavaScript that SO uses to display how many characters you can add to your comment available somewhere or is it "private", as it not available for download legally? I'm looking to do something quite similar.

The reason I ask is mostly because I don't want to rewrite something that has been done hundreds of times and the SO one is done really well.

+1  A: 

I wrote a similar script as a jQuery plugin, the code is available here.

$('input').charLimit(); // with default options

$('textarea').charLimit({ 
  length: 300, // maximum number of characters
  message: 'avail chars', // text to show after the number
  truncate: true, // don't allow to enter more text than length 
  normalColor: '#000000', // color of the character counter text 
  warningColor: '#FF0000', // color of the text when the limit has exceeded 
});

You can see the plugin working in this example.

CMS
Looks good. It doesn't do the warning colour though before they reach the limit :(
Darryl Hein