diff --git a/modules/checkout/includes/commerce_checkout.pages.inc b/modules/checkout/includes/commerce_checkout.pages.inc
index 4e420fb..ed5e237 100644
--- a/modules/checkout/includes/commerce_checkout.pages.inc
+++ b/modules/checkout/includes/commerce_checkout.pages.inc
@@ -91,6 +91,7 @@ function commerce_checkout_form($form, &$form_state, $order, $checkout_page) {
     $form_errors = &drupal_static('form_set_error', array());
     $form_errors = $form_state['storage']['errors'];
   }
+  $form['#after_build'] = array('commerce_checkout_form_process_errors');
 
   // Catch and clear already pushed messages.
   $previous_messages = drupal_get_messages();
@@ -223,6 +224,42 @@ function commerce_checkout_form($form, &$form_state, $order, $checkout_page) {
 }
 
 /**
+ * after_build callback for the checkout form.
+ */
+function commerce_checkout_form_process_errors($form, $form_state) {
+
+  // Do this only on form rebuild (when the form will not be validated anymore):
+  if (!empty($form_state['storage']['errors']) && !empty($form_state['rebuild'])) {
+    foreach (array_keys($form_state['storage']['errors']) as $element_name) {
+      // Look for all elements which have $element_name as parents, and
+      // restore their #validated property (so _form_set_class() will set
+      // the error class even though the rebuilt form is not validated).
+      // We can't simply use drupal_array_get_nested_value(), since the #parents
+      // property may have been changed and not match the form structure.
+      _commerce_checkout_set_validated($form, $element_name);
+    }
+  }
+
+  return $form;
+}
+
+/**
+ * Set '#validated' on elements which have the specified parents.
+ */
+function _commerce_checkout_set_validated(&$element, $parents_imp) {
+
+  foreach (element_children($element) as $key) {
+    _commerce_checkout_set_validated($element[$key], $parents_imp);
+  }
+
+  // This will also set #validated on all elements where #needs_validation would
+  // be FALSE, but that doesn't hurt anything.
+  if (!empty($element['#parents']) && strpos($parents_imp, implode('][', $element['#parents'])) === 0) {
+    $element['#validated'] = TRUE;
+  }
+}
+
+/**
  * Validate handler for the continue button of the checkout form.
  *
  * This function calls the validation function of each pane, followed by
