Index: includes/form.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/form.inc,v retrieving revision 1.265 diff -u -r1.265 form.inc --- includes/form.inc 4 Feb 2008 10:23:32 -0000 1.265 +++ includes/form.inc 5 Feb 2008 00:25:10 -0000 @@ -661,14 +661,18 @@ _form_validate($elements[$key], $form_state); } } + // Validate the current input. if (!isset($elements['#validated']) || !$elements['#validated']) { if (isset($elements['#needs_validation'])) { - // We only check for trimmed string length being zero. 0 might be - // a possible value with some field types, such as radio buttons, so - // empty() is not usable here. - if ($elements['#required'] && strlen(trim($elements['#value'])) == 0) { - form_error($elements, $t('!name field is required.', array('!name' => $elements['#title']))); + + // Validate required form items: + // Count() checks if the item (string, array, integer) contains anything. + // Beyond that, strings are checked not to be empty after being trimmed. + if ($elements['#required']) { + if ((!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.