Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.112.2.14
diff -u -r1.112.2.14 form.inc
--- includes/form.inc	4 Jul 2006 09:23:19 -0000	1.112.2.14
+++ includes/form.inc	12 Jul 2006 03:18:24 -0000
@@ -1162,6 +1162,9 @@
 
 /**
  * Remove invalid characters from an HTML ID attribute string.
+ * Inserts 'n' before an ID that begins with a numeric character.
+ * Replaces space, underscore and ][ with hyphen.
+ * Converts entire string to lowercase.
  *
  * @param $id
  *   The ID to clean
@@ -1169,8 +1172,11 @@
  *   The cleaned ID
  */
 function form_clean_id($id = NULL) {
+  if (is_numeric($id[0])) {
+    $string = 'n'. $string;
+  }
   $id = str_replace('][', '-', $id);
-  return $id;
+  return strtolower(preg_replace('/[^a-zA-Z0-9-]+/', '-', $id));
 }
 
 /**
