diff --git a/includes/form.inc b/includes/form.inc
index a57ffa2b20f3f9f6b7d837d1771fe875656e1612..300b78267c0b9c3f05b472107e5768960e67897c 100644
--- a/includes/form.inc
+++ b/includes/form.inc
@@ -145,6 +145,24 @@ function _form_validate($elements, $form_id = NULL) {
     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']) && isset($elements['#value'])) {
+      $message = t('Illegal choice in %title.', array('%title' => theme('placeholder', $elements['#title'])));
+      if (is_array($elements['#value'])) {
+        $value = $elements['#type'] == 'checkboxes' ? array_keys(array_filter($elements['#value'])) : $elements['#value'];
+        foreach ($value as $v) {
+          if (!isset($elements['#options'][$v])) {
+            form_error($elements, $message);
+          }
+        }
+      }
+      elseif (!isset($elements['#options'][$elements['#value']])) {
+        form_error($elements, $message);
+      }
+    }
+
+    // User-applied checks.
     if (isset($elements['#validate'])) {
       foreach ($elements['#validate'] as $function => $args) {
         $args = array_merge(array($elements), $args);
diff --git a/modules/filter.module b/modules/filter.module
index 88cb98801705aed01694be8b1d3fe42fa17f0d94..b810398794c8ec2eaa2ef6f4737188f93e703a39 100644
--- a/modules/filter.module
+++ b/modules/filter.module
@@ -775,7 +775,6 @@ function filter_form($value = FILTER_FORMAT_DEFAULT, $weight = 0, $parents = arr
         '#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_FORMAT_DEFAULT, $weight = 0, $parents = arr
   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.
  */
diff --git a/modules/filter/filter.module b/modules/filter/filter.module
index 88cb98801705aed01694be8b1d3fe42fa17f0d94..b810398794c8ec2eaa2ef6f4737188f93e703a39 100644
--- a/modules/filter/filter.module
+++ b/modules/filter/filter.module
@@ -775,7 +775,6 @@ function filter_form($value = FILTER_FORMAT_DEFAULT, $weight = 0, $parents = arr
         '#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_FORMAT_DEFAULT, $weight = 0, $parents = arr
   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.
  */