Created
July 6, 2010 21:06
-
-
Save todoubled/465912 to your computer and use it in GitHub Desktop.
Character Count
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function() { | |
$('#post_message').keyup(function() { | |
var content_length = $(this).val().length; | |
var remaining = 420 - content_length | |
$('.counter').html(remaining); | |
if (remaining < 0) { | |
$('input[type=submit]').attr("disabled", "disabled"); | |
} else if (remaining < 21 && remaining > 9) { | |
$('input[type=submit]').removeAttr("disabled"); | |
$('.counter').removeClass('red'); | |
$('.counter').addClass('dark_red'); | |
} else if (remaining <= 9) { | |
$('input[type=submit]').removeAttr("disabled"); | |
$('.counter').removeClass('dark_red'); | |
$('.counter').addClass('red'); | |
} else { | |
$('input[type=submit]').removeAttr("disabled"); | |
$('.counter').removeClass('dark_red').removeClass('red'); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment