=== modified file 'includes/form.inc'
--- includes/form.inc	
+++ includes/form.inc	
@@ -145,6 +145,15 @@ function _form_validate($elements, $form
     if ($elements['#required'] && empty($elements['#value']) && $elements['#value'] !== '0') {
       form_error($elements, t('%name field is required', array('%name' => $elements['#title'])));
     }
+
+    // Add legal choice check if element has #options.
+    if (isset($elements['#options'])) {
+      if (!isset($elements['#validate']['form_legal_choice'])) {
+        $elements['#validate']['form_legal_choice_check'] = array();
+      }
+    }
+
+    // User-applied checks.
     if (isset($elements['#validate'])) {
       foreach ($elements['#validate'] as $function => $args) {
         $args = array_merge(array($elements), $args);
@@ -169,6 +178,38 @@ function _form_validate($elements, $form
 }
 
 /**
+ * Validator: Legal choice check.
+ *
+ * @param mixed $element
+ *   The element to be checked.
+ * @return none
+ *   Performs a form_set_error() if invalid choice is discovered.
+ */
+function form_legal_choice_check($element, $msg = null) {
+  $value = $element['#value'];
+  $options = $element['#options'];
+  if (!isset($value)) {
+    return; // allow no choice
+  }
+  if (!is_array($options)) { // if no options set an error
+    form_error($element, isset($msg) ? $msg : t('Illegal choice (none provided).'));
+  }
+  if (!isset($msg)) {
+    $msg = t('Illegal choice in %title.', array('%title' => theme('placeholder', $element['#title'])));
+  }
+  if (is_array($value)) {
+    foreach ($value as $v) {
+      if (!isset($options[$v])) {
+        form_error($element, $msg);
+      }
+    }
+  }
+  elseif (!isset($options[$value])) {
+    form_error($element, $msg);
+  }
+}
+
+/**
  * File an error against a form element. If the name of the element is
  * edit[foo][bar] then you may pass either foo or foo][bar as $name
  * foo will set an error for all its children.
=== modified file 'modules/filter.module'
--- modules/filter.module	
+++ modules/filter.module	
@@ -775,7 +775,6 @@ function filter_form($value = FILTER_FOR
         '#return_value' => $format->format,
         '#parents' => $parents,
         '#description' => theme('filter_tips', _filter_tips($format->format, false)),
-        '#validate' => array('filter_form_validate' => array())
       );
     }
   }
@@ -793,18 +792,6 @@ function filter_form($value = FILTER_FOR
   return $form;
 }
 
-function filter_form_validate($element) {
-  static $validated;
-  if ($validated) {
-    return;
-  }
-  $validated = 1;
-  $formats = filter_formats();
-  if (!isset($formats[$element['#value']])) {
-    form_set_error($element['#parents'][0], t('The supplied input format is invalid.'));
-  }
-}
-
 /**
  * Returns true if the user is allowed to access this format.
  */
