(function ($) { Drupal.behaviors.pageTitleFieldsetSummaries = { attach: function (context) { $('fieldset#edit-page-title', context).drupalSetSummary(function (context) { var pt = $('input', context).val(); return pt ? Drupal.t('Page Title: @pt', { '@pt': pt }) : Drupal.t('No Page Title'); }); } }; Drupal.behaviors.pageTitleCounter = { attach : function(context) { $('fieldset#edit-page-title', context).each(function() { function getLength(element) { return $(element).val().length; } var wrapper = this; var inputBox = $('input[name=page_title]', wrapper); var valueBox = $('div.description', wrapper) .append('
Characters Entered: 0') .find('.value') .text(getLength(inputBox)); $('input[name=page_title]', wrapper).keyup(function(e) { $(valueBox).text(getLength(inputBox)); }); }); } } })(jQuery);