December 4, 201312 yr Hey all. I'm using the following javascript to count the characters in several text areas and it works fine when you start typing. I need it to show the characters in the text area once the page has loaded then to continue counting when a user adds to the text. I'm guessing I need something other than keyup to check the characters once the page has loaded? Thanks $(document).ready(function() { $('.countThisA').keyup(function() { var cs = $(this).val().length; $('#countA').val(cs); }); $('.countThisB').keyup(function() { var cs = $(this).val().length; $('#countB').val(cs); }); });
December 4, 201312 yr This should work, and it's a bit more expandable. Add as many fields as you need without needing more Javascript. http://jsfiddle.net/bkXw3/
Create an account or sign in to comment