Created
August 20, 2012 15:51
-
-
Save cam-gists/3405317 to your computer and use it in GitHub Desktop.
JQuery: Charecter Counter
This file contains hidden or 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
| // controls character input/counter | |
| $('textarea#body').keyup(function() { | |
| var charLength = $(this).val().length; | |
| // Displays count | |
| $('span#charCount').html(charLength + ' of 250 characters used'); | |
| // Alerts when 250 characters is reached | |
| if($(this).val().length > 250) | |
| $('span#charCount').html('<strong>You may only have up to 250 characters.</strong>'); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment