I have a few areas on my site where I need to limit text input to X amount of characters and it\'s nice to show a number of spaces left while a user types in, like twitter d
Using jQuery, assuming that you have a textarea with id field that you wish to limit to 100 characters, and another element with id chars-remaining to display the number of available characters:
var max = 100;
$('#field').keyup(function() {
if($(this).val().length > max) {
$(this).val($(this).val().substr(0, max));
}
$('#chars-remaining').html((max - $(this).val().length) + ' characters remaining');
});