Index: maxlength.inc
===================================================================
--- maxlength.inc	(revision 731)
+++ maxlength.inc	(working copy)
@@ -10,13 +10,23 @@
   // update the title as needed
   if (isset($form['title'])) {
     $form['title']['#after_build'] = array('_maxlength_format_element');
-    $form['title']['#max_length_properties'] = array($form['title']['#default_value'], 'title', 'title', $type);
+    $form['title']['#max_length_properties'] = array(
+      'value' => $form['title']['#default_value'], 
+      'field' => 'title', 
+      'id' => 'title', 
+      'type' => $type,
+    );
   }
 
   // Update the body as needed
   if (isset($form['body_field']['body'])) {
     $form['body_field']['body']['#after_build'] = array('_maxlength_format_element');
-    $form['body_field']['body']['#max_length_properties'] = array($form['body_field']['body']['#default_value'], 'body', 'body', $type);
+    $form['body_field']['body']['#max_length_properties'] = array(
+      'value' => $form['body_field']['body']['#default_value'], 
+      'field' => 'body', 
+      'id' => 'body', 
+      'type' => $type,
+    );
   }
 
 
@@ -30,7 +40,12 @@
         foreach (element_children($form[$field]) as $key) {
           if ($form[$field][$key]['#type'] == 'text_textarea' || $form[$field][$key]['#type'] == 'text_textfield') {
             $form[$field][$key]['#after_build'] = array('_maxlength_format_element');
-            $form[$field][$key]['#max_length_properties'] = array($form[$field][$key]['#default_value']['value'], $field, str_replace('_', '-', $field) .'-'. $key .'-value', $type);
+            $form[$field][$key]['#max_length_properties'] = array(
+              'value' => $form[$field][$key]['#default_value']['value'], 
+              'field' => $field, 
+              'id' => str_replace('_', '-', $field) .'-'. $key .'-value', 
+              'type' => $type,
+            );
           }
         }
       }
@@ -114,7 +129,19 @@
   variable_set('maxlength_' . $form['field_name']['#value'] .'_text', $form['#post']['maxlength_' . $form['field_name']['#value'] .'_text']);
 }
 
-function _maxlength_get_values($field = 'body', $type = '') {
+function _maxlength_form_fields_alter(&$form, $form_state, $form_id, $fields) {
+  foreach ($fields as $field=>$values) {
+    if (!isset($form[$field])) continue;
+    $form[$field]['#after_build'] = array('_maxlength_format_element');
+    $form[$field]['#max_length_properties'] = array(
+      'value' => $form[$field]['#default_value'],
+      'settings' => $values,
+      'id' => (empty($values['id']) ? $field : $values['id']),
+    );
+  }
+}
+
+function _maxlength_get_settings($field = 'body', $type = '') {
   $values = '';
   $values['limit'] = FALSE;
 
@@ -123,7 +150,8 @@
     $values['limit'] = variable_get('maxlength_' . $field, FALSE);
     $values['use_js'] = variable_get('maxlength_' . $field .'_js', FALSE);
     $values['text'] = variable_get('maxlength_' . $field .'_text', FALSE);
-  } //body and title
+  } 
+  //body and title
   elseif ($type != '') {
     $values['limit'] = variable_get('maxlength_' . $field .'_'. $type, FALSE);
     $values['use_js'] = variable_get('maxlength_' . $field .'_js_'. $type, FALSE);
Index: maxlength.module
===================================================================
--- maxlength.module	(revision 731)
+++ maxlength.module	(working copy)
@@ -22,6 +22,8 @@
  * Implementation of hook_form_alter().
  */
 function maxlength_form_alter(&$form, &$form_state, $form_id) {
+  static $form_fields = array();
+  
   // Editing the content
   if ($form['#id'] == 'node-form') {
     module_load_include('inc', 'maxlength', 'maxlength');
@@ -46,6 +48,20 @@
     variable_del('maxlength_' . $form['field_name']['#value'] .'_js');
     variable_del('maxlength_' . $form['field_name']['#value'] .'_text');
   }
+
+  // Other form fields provided by hook_maxlength_form_fields
+  else {
+    if (empty($form_fields)) {
+      foreach (module_implements('maxlength_form_fields') as $module) {
+        $get_form_fields = $module . '_maxlength_form_fields';
+        $form_fields = array_merge($get_form_fields(), $form_fields);
+      }
+    }
+    if (isset($form_fields[$form_id])) {
+      module_load_include('inc', 'maxlength', 'maxlength');
+      _maxlength_form_fields_alter($form, $form_state, $form_id, $form_fields[$form_id]);
+    }
+  }
 }
 
 /**
@@ -116,43 +132,44 @@
 function _maxlength_format_element($element) {
   static $processed = array();
   module_load_include('inc', 'maxlength', 'maxlength');
-  $value = $element['#max_length_properties'][0];
-  $field = $element['#max_length_properties'][1];
-  $id = $element['#max_length_properties'][2];
-  $type = $element['#max_length_properties'][3];
+  
+  // creates variables: $value, $id, $type, and $field or $settings
+  extract($element['#max_length_properties']);
 
-  $values = _maxlength_get_values($field, $type);
-
-  if ($values !== FALSE && isset($values['limit']) && $values['limit'] && $values['use_js']) {
+  if (empty($settings)) {
+    $settings = _maxlength_get_settings($field, $type);
+  }
+  
+  if ($settings !== FALSE && !empty($settings['limit']) && $settings['use_js']) {
     $path = drupal_get_path('module', 'maxlength');
     drupal_add_js($path .'/maxlength.js');
 
-    $remaining = $values['limit'] - drupal_strlen($value);
+    $remaining = $settings['limit'] - drupal_strlen($value);
 
     if ($remaining < 0) {
       drupal_set_message(
         t('%body_field_label truncated to %limit characters!',
         array(
           '%body_field_label' => $element['#title'],
-          '%limit' => $values['limit'])
+          '%limit' => $settings['limit'])
         ),
         'error'
       );
 
-      $element['#default_value'] = drupal_substr($element['#default_value'], 0, $values['limit']);
+      $element['#default_value'] = drupal_substr($element['#default_value'], 0, $settings['limit']);
       $remaining = 0;
     }
 
     if (in_array($element['#id'], $processed) === FALSE) {
       $js_settings = array(
         'maxlength' => array(
-          'edit-'. $id => $values['limit'],
+          'edit-'. $id => $settings['limit'],
         ),
       );
       drupal_add_js($js_settings, 'setting');
     }
     $element['#suffix'] = '<div id="maxlength-'. $id .'"
-      class="maxlength-counter">' . t($values['text'], array('!limit' => $values['limit'], '!count' => '<span class="maxlength-count">' . drupal_strlen($value) .'</span>', '!remaining' => '<span class="maxlength-counter-remaining">' . $remaining . '</span>')) . '</div>';
+      class="maxlength-counter">' . t($settings['text'], array('!limit' => $settings['limit'], '!count' => '<span class="maxlength-count">' . drupal_strlen($value) .'</span>', '!remaining' => '<span class="maxlength-counter-remaining">' . $remaining . '</span>')) . '</div>';
     $processed[] = $element['#id'];
   }
   return $element;
