Index: components/time.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/time.inc,v
retrieving revision 1.31
diff -u -r1.31 time.inc
--- components/time.inc	25 Mar 2010 01:09:50 -0000	1.31
+++ components/time.inc	26 Mar 2010 00:00:43 -0000
@@ -169,14 +169,31 @@
   return $element;
 }
 
+/**
+ * Theme a webform time element.
+ */
+function theme_webform_time($variables) {
+  $element = $variables['element'];
+
+  // Add error classes to all items within the element.
+  if (form_get_error($element)) {
+    $element['hour']['#attributes']['class'] = array('error');
+    $element['minute']['#attributes']['class'] = array('error');
+  }
+
+  $output = '<div class="container-inline">' . drupal_render($element['hour']) . drupal_render($element['minute']) . drupal_render($element['ampm']) . '</div>';
+
+  return $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;
     }
   }
@@ -352,14 +369,3 @@
 
   return $array;
 }
-
-/**
- * Theme a webform time element.
- */
-function theme_webform_time($variables) {
-  $element = $variables['element'];
-  $element['#type'] = 'element';
-  $element['#children'] = '<div class="container-inline">' . drupal_render($element['hour']) . drupal_render($element['minute']) . drupal_render($element['ampm']) . '</div>';
-
-  return $element['#children'];
-}
Index: components/date.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/date.inc,v
retrieving revision 1.36
diff -u -r1.36 date.inc
--- components/date.inc	21 Mar 2010 03:38:25 -0000	1.36
+++ components/date.inc	26 Mar 2010 00:00:43 -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'),
   );
 
@@ -196,6 +197,26 @@
 }
 
 /**
+ * Theme a webform date element.
+ */
+function theme_webform_date($variables) {
+  $element = $variables['element'];
+
+  // Add error classes to all items within the element.
+  if (form_get_error($element)) {
+    $element['year']['#attributes']['class'] = array('error');
+    $element['month']['#attributes']['class'] = array('error');
+    $element['day']['#attributes']['class'] = array('error');
+  }
+
+  $output = '';
+  $output .= '<div class="container-inline">';
+  $output .= drupal_render_children($element);
+  $output .= '</div>';
+  return $output;
+}
+
+/**
  * Element validation for Webform date fields.
  */
 function webform_validate_date($element, $form_state) {
@@ -206,14 +227,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;
     }
   }
@@ -223,7 +244,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;
     }
   }
