Index: components/time.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/time.inc,v
retrieving revision 1.24.2.7
diff -u -r1.24.2.7 time.inc
--- components/time.inc	25 Mar 2010 01:09:51 -0000	1.24.2.7
+++ components/time.inc	26 Mar 2010 00:00:26 -0000
@@ -174,14 +174,30 @@
   return $element;
 }
 
+/**
+ * Theme a webform time element.
+ */
+function theme_webform_time($element) {
+  // Add error classes to all items within the element.
+  if (form_get_error($element)) {
+    $element['hour']['#attributes']['class'] = 'error';
+    $element['minute']['#attributes']['class'] = 'error';
+  }
+
+  $output = '<div class="container-inline">' . drupal_render($element['hour']) . drupal_render($element['minute']) . drupal_render($element['ampm']) . '</div>';
+
+  $element['#type'] = 'element';
+  return theme('form_element', $element, $output);
+}
+
 function webform_validate_time($element, $form_state) {
   $form_key = $element['#webform_component']['form_key'];
   $name = $element['#webform_component']['name'];
 
   // Check if the user filled the required fields.
   foreach ($element['#hourformat'] == '12-hour' ? array('hour', 'minute', 'ampm') : array('hour', 'minute') as $field_type) {
-    if (!is_numeric($element[$field_type]['#value']) && $element['#required']) {
-      form_error($element[$field_type], t('%field field is required.', array('%field' => $name)));
+    if ($element[$field_type]['#value'] == '' && $element['#required']) {
+      form_error($element, t('%field field is required.', array('%field' => $name)));
       return;
     }
   }
@@ -326,16 +342,6 @@
 }
 
 /**
- * Theme a webform time element.
- */
-function theme_webform_time($element) {
-  $element['#type'] = 'element';
-  $element['#children'] = '<div class="container-inline">' . drupal_render($element['hour']) . drupal_render($element['minute']) . drupal_render($element['ampm']) . '</div>';
-
-  return theme('form_element', $element, $element['#children']);
-}
-
-/**
  * Convert a time between a 24-hour and a 12-hour value.
  *
  * @param $array
Index: components/date.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/date.inc,v
retrieving revision 1.29.2.6
diff -u -r1.29.2.6 date.inc
--- components/date.inc	21 Mar 2010 03:38:12 -0000	1.29.2.6
+++ components/date.inc	26 Mar 2010 00:00:26 -0000
@@ -113,6 +113,7 @@
     '#required' => $component['mandatory'],
     '#webform_component' => $component,
     '#process' => array('webform_expand_date'),
+    '#theme' => 'webform_date',
     '#element_validate' => array('webform_validate_date'),
   );
 
@@ -202,6 +203,26 @@
 }
 
 /**
+ * Theme a webform date element.
+ */
+function theme_webform_date($element) {
+  // Add error classes to all items within the element.
+  if (form_get_error($element)) {
+    $element['year']['#attributes']['class'] = 'error';
+    $element['month']['#attributes']['class'] = 'error';
+    $element['day']['#attributes']['class'] = 'error';
+  }
+
+  $output = '';
+  $output .= '<div class="container-inline">';
+  foreach (element_children($element) as $key) {
+    $output .= drupal_render($element[$key]);
+  }
+  $output .= '</div>';
+  return $output;
+}
+
+/**
  * Element validation for Webform date fields.
  */
 function webform_validate_date($element, $form_state) {
@@ -212,14 +233,14 @@
   // Check if the user filled the required fields.
   foreach (array('day', 'month', 'year') as $field_type) {
     if (!is_numeric($element[$field_type]['#value']) && $element['#required']) {
-      form_set_error($form_key, t('!name field is required.', array('!name' => $name)));
+      form_error($element, t('!name field is required.', array('!name' => $name)));
       return;
     }
   }
   // Check for a valid date.
   if ($element['month']['#value'] !== '' || $element['day']['#value'] !== '' || $element['year']['#value'] !== '') {
     if (!checkdate((int)$element['month']['#value'], (int)$element['day']['#value'], (int)$element['year']['#value'])) {
-      form_set_error($form_key, t('Entered !name is not a valid date.', array('!name' => $name)));
+      form_error($element, t('Entered !name is not a valid date.', array('!name' => $name)));
       return;
     }
   }
@@ -229,7 +250,7 @@
     $start = $component['extra']['year_start'] < $component['extra']['year_end'] ? $component['extra']['year_start'] : $component['extra']['year_end'];
     $end   = $component['extra']['year_start'] > $component['extra']['year_end'] ? $component['extra']['year_start'] : $component['extra']['year_end'];
     if ($element['year']['#value'] < $start || $element['year']['#value'] > $end) {
-      form_set_error($form_key . '][year', t('The entered date needs to be between the years @start and @end.', array('@start' => $start, '@end' => $end)));
+      form_error($element['year'], t('The entered date needs to be between the years @start and @end.', array('@start' => $start, '@end' => $end)));
       return;
     }
   }
