Skip to content

Instantly share code, notes, and snippets.

@mckellip
mckellip / Text Area Max Length
Created August 22, 2012 17:05
Add max length and character counter to html text areas using jquery
/* HTML Needed
* <textarea id="area1" maxlength="250"></textarea>
* <span class="area1"></span>
*/
$('textarea[maxlength]').on('focus keyup', function (e) {
var ml = this.getAttribute('maxlength');
var c = $('.' + this.id);
var tv = this.value;
var l = tv.length;
if (e.type === 'focus') {