? 858614-maxlength-multiple-fields.patch
Index: maxlength.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/maxlength/maxlength.js,v
retrieving revision 1.1.6.6.2.13
diff -u -p -r1.1.6.6.2.13 maxlength.js
--- maxlength.js	27 Jun 2010 07:44:50 -0000	1.1.6.6.2.13
+++ maxlength.js	21 Oct 2010 20:08:01 -0000
@@ -23,12 +23,15 @@ Drupal.maxLength_limit = function (field
 
 Drupal.behaviors.maxlength = function (context) {
   // Get all the settings, and save the limits in the fields.
+  var maxlengths = new Array();
+  var elements = new Array();
   var maxlength = {};
   var element = {};
   var limit = 50;
   for (var id in Drupal.settings.maxlength) {
     limit = Drupal.settings.maxlength[id];
     element = $("#"+ id);
+    elements[element.attr('id')] = element;
     maxlength = $('#maxlength-' + element.attr('id').substr(5));
 
     maxlength.limit = limit;
@@ -39,17 +42,19 @@ Drupal.behaviors.maxlength = function (c
       maxlength.span_count = maxlength.find('span.maxlength-count');
     });
 
+    maxlengths[element.attr('id')] = maxlength;
+
     // Update the count at the page load.
-    Drupal.maxLength_limit(element, maxlength);
+    Drupal.maxLength_limit(element, maxlengths[id]);
 
     element.load(function() {
-      Drupal.maxLength_limit(element, maxlength);
+      Drupal.maxLength_limit(elements[$(this).attr('id')], maxlengths[$(this).attr('id')]);
     });
     element.keyup(function() {
-      Drupal.maxLength_limit(element, maxlength);
+      Drupal.maxLength_limit(elements[$(this).attr('id')], maxlengths[$(this).attr('id')]);
     });
     element.change(function() {
-      Drupal.maxLength_limit(element, maxlength);
+      Drupal.maxLength_limit(elements[$(this).attr('id')], maxlengths[$(this).attr('id')]);
     });
   }
 }
