diff --git a/modules/dialog_user/dialog_user.module b/modules/dialog_user/dialog_user.module
index 8f0120d..68e9eca 100644
--- a/modules/dialog_user/dialog_user.module
+++ b/modules/dialog_user/dialog_user.module
@@ -47,11 +47,25 @@ function dialog_user_ajax_callback($type, $js) {
       $path = 'user/pass';
       break;
   }
-
   if ($js) {
+    // Set dialog display to be true initially.  If this is the first time
+    // the form is being rendered inside of the dialog we want dialog_display to be
+    // true.
     dialog_display(TRUE);
     $content = drupal_get_form($form_id);
-    $output[] = dialog_command_display($content, array('title' => $title));
+    // If the form has been submitted from within the dialog and it has passed
+    // validation and has been submitted, the dialog_display() function will have
+    // been updated to return false (see dialog_user_ajax_form_submit()).
+    // This is desired because if form submission completed without error
+    // we want to dismiss the dialog and refresh the page.
+    // If dialog_display() returns true, we're either showing the form for the first time
+    // or redrawing the form after a validation error.
+    if (dialog_display()) {
+      $output[] = dialog_command_display($content, array('title' => $title));
+    }
+    else {
+      $output[] = dialog_command_reload();
+    }
     ajax_deliver(array('#type' => 'ajax', '#commands' => $output));
   }
   else {
@@ -70,30 +84,12 @@ function dialog_user_form_alter(&$form, &$form_state, $form_id) {
       $form['#prefix'] = '<div id="dialog-form-wrapper">';
       $form['#suffix'] = '</div>';
 
-      // Make enter press work on textfields.
-      $textfields = array('name', 'pass', 'email');
-      foreach ($textfields as $textfield) {
-        if (isset($form[$textfield])) {
-          $form[$textfield]['#ajax'] = array(
-            'event' => '',
-            'keypress' => TRUE,
-            'callback' => 'drupal_render',
-            'wrapper' => 'dialog-form-wrapper',
-          );
-        }
-        if (isset($form['account'][$textfield])) {
-          $form['account'][$textfield]['#ajax'] = array(
-            'event' => '',
-            'keypress' => TRUE,
-            'callback' => 'drupal_render',
-            'wrapper' => 'dialog-form-wrapper',
-          );
-        }
-      }
-
-      $form['submit']['#ajax'] = array(
-        'callback' => 'drupal_render',
-        'wrapper' => 'dialog-form-wrapper',
+      //  Submit form via AJAX from within dialog.
+      //  Do this instead of using adding #ajax to the submit button
+      //  so that ajax call is made to the callback handler we defined rather
+      //  than system/ajax.
+      $form['actions']['submit']['#attributes'] = array (
+        'class' => array('use-ajax-submit')
       );
 
       $form['#submit'][] = 'dialog_user_ajax_form_submit';
@@ -106,9 +102,11 @@ function dialog_user_form_alter(&$form, &$form_state, $form_id) {
  * Ajax submit handler for forms inside dialogs.
  */
 function dialog_user_ajax_form_submit(&$form, &$form_state) {
-  if (isset($form_state['redirect'])) {
-    $commands = array();
-    $commands[] = dialog_command_redirect($form_state['redirect']);
-    ajax_render($commands);
-  }
+  // Unset dialog_display static variable.  It was set and is useful when
+  // the form is first generated inside the dialog window.  But at this stage
+  // we no longer want to display a dialog.  In fact we want to eventually dismiss it.
+  drupal_static_reset('dialog_display');
+  // We also don't want to redirect the form needlessly.  The rediected
+  // page would have loaded in the dialog.  We'll be dismissing that dialog.
+  $form_state['no_redirect'] = true;
 }
