Skip to content

Instantly share code, notes, and snippets.

@jtmkrueger
Created March 15, 2012 17:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtmkrueger/2045436 to your computer and use it in GitHub Desktop.
Save jtmkrueger/2045436 to your computer and use it in GitHub Desktop.
character counter
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