Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.343
diff -u -r1.343 form.inc
--- includes/form.inc	20 Jun 2009 15:17:38 -0000	1.343
+++ includes/form.inc	21 Jun 2009 13:43:17 -0000
@@ -744,10 +744,18 @@
       // A simple call to empty() will not cut it here as some fields, like
       // checkboxes, can return a valid value of '0'. Instead, check the
       // length if it's a string, and the item count if it's an array.
-      if ($elements['#required'] && (!count($elements['#value']) || (is_string($elements['#value']) && strlen(trim($elements['#value'])) == 0))) {
-        form_error($elements, $t('!name field is required.', array('!name' => $elements['#title'])));
+      if ($elements['#required'] || isset($elements['#required_validate'])) {
+        if (isset($elements['#required_validate'])) {
+          foreach ($elements['#required_validate'] as $function) {
+            if (function_exists($function))  {
+              $function($elements, $form_state, $complete_form);
+            }
+          }
+        }
+        elseif (!count($elements['#value']) || (is_string($elements['#value']) && strlen(trim($elements['#value'])) == 0)) {
+          form_error($elements, $t('!name field is required.', array('!name' => $elements['#title'])));
+        }
       }
-
       // Verify that the value is not longer than #maxlength.
       if (isset($elements['#maxlength']) && drupal_strlen($elements['#value']) > $elements['#maxlength']) {
         form_error($elements, $t('!name cannot be longer than %max characters but is currently %length characters long.', array('!name' => empty($elements['#title']) ? $elements['#parents'][0] : $elements['#title'], '%max' => $elements['#maxlength'], '%length' => drupal_strlen($elements['#value']))));
