Created
March 15, 2012 17:23
-
-
Save jtmkrueger/2045436 to your computer and use it in GitHub Desktop.
character counter
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
init = 1100 | |
notes_length = $('#notes_length') | |
desc = $('#description') | |
chars = desc.val().length | |
notes_length.html(init - chars) | |
check = -> | |
console.log notes_length.html() | |
if notes_length.html() < 0 | |
notes_length.css('color', 'red') | |
$('input.create').attr('disabled', 'disabled').addClass('disabled') | |
else | |
notes_length.css('color', 'black') | |
$('.create').removeAttr('disabled').removeClass('disabled') | |
check() | |
desc.live('keyup keypress cut copy paste mouseup mousedown click focusout', -> | |
chars = desc.val().length | |
notes_length.html(init - chars) | |
check() | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment