Index: modules/comment/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v
retrieving revision 1.812
diff -u -p -r1.812 comment.module
--- modules/comment/comment.module	1 Dec 2009 16:03:35 -0000	1.812
+++ modules/comment/comment.module	1 Dec 2009 21:16:00 -0000
@@ -1727,6 +1727,8 @@ function comment_form($form, &$form_stat
     // If the comment is by a registered user, allow to autocomplete username.
     if ($comment->registered_name != '') {
       $form['author']['name']['#autocomplete_path'] = 'user/autocomplete';
+      $form['author']['name']['#element_validate'] = array('user_element_validate_name_autocomplete');
+      $form['author']['name']['#required'] = TRUE;
     }
   }
   elseif ($user->uid) {
@@ -1927,9 +1929,6 @@ function comment_form_validate($form, &$
     if ($form_state['values']['date'] && strtotime($form_state['values']['date']) === FALSE) {
       form_set_error('date', t('You have to specify a valid date.'));
     }
-    if ($form_state['values']['name'] && !$account = user_load_by_name($form_state['values']['name'])) {
-      form_set_error('name', t('You have to specify a valid author.'));
-    }
   }
 
   // Check validity of name, mail and homepage (if given).
Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.1171
diff -u -p -r1.1171 node.module
--- modules/node/node.module	1 Dec 2009 13:14:42 -0000	1.1171
+++ modules/node/node.module	1 Dec 2009 21:12:53 -0000
@@ -890,14 +890,6 @@ function node_validate($node, $form = ar
   }
 
   if (user_access('administer nodes')) {
-    // Validate the "authored by" field.
-    if (!empty($node->name) && !($account = user_load_by_name($node->name))) {
-      // The use of empty() is mandatory in the context of usernames
-      // as the empty string denotes the anonymous user. In case we
-      // are dealing with an anonymous user we set the user ID to 0.
-      form_set_error('name', t('The username %name does not exist.', array('%name' => $node->name)));
-    }
-
     // Validate the "authored on" field.
     if (!empty($node->date) && strtotime($node->date) === FALSE) {
       form_set_error('date', t('You have to specify a valid date.'));
Index: modules/node/node.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.pages.inc,v
retrieving revision 1.102
diff -u -p -r1.102 node.pages.inc
--- modules/node/node.pages.inc	1 Dec 2009 16:03:35 -0000	1.102
+++ modules/node/node.pages.inc	1 Dec 2009 21:16:34 -0000
@@ -216,6 +216,7 @@ function node_form($form, &$form_state, 
     '#title' => t('Authored by'),
     '#maxlength' => 60,
     '#autocomplete_path' => 'user/autocomplete',
+    '#element_validate' => array('user_element_validate_name_autocomplete'),
     '#default_value' => !empty($node->name) ? $node->name : '',
     '#weight' => -1,
     '#description' => t('Leave blank for %anonymous.', array('%anonymous' => variable_get('anonymous', t('Anonymous')))),
Index: modules/user/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.1087
diff -u -p -r1.1087 user.module
--- modules/user/user.module	1 Dec 2009 16:03:35 -0000	1.1087
+++ modules/user/user.module	1 Dec 2009 21:16:53 -0000
@@ -590,6 +590,27 @@ function user_validate_picture(&$form, &
 }
 
 /**
+ * Form element validation handler to validate an autocompleted username.
+ *
+ * This function may be specified as #element_validate handler for any form
+ * element that expects a valid, existing username as value.
+ *
+ * Form elements should additionally set #required => TRUE when a valid user is
+ * required. Otherwise, it is assumed that an empty string will be used to
+ * denote the anonymous user.
+ *
+ * To validate the syntax of a username during registration, use
+ * user_validate_name() instead.
+ */
+function user_element_validate_name_autocomplete($element) {
+  // The condition of an empty string is mandatory in the context of usernames,
+  // since an empty string denotes the anonymous user.
+  if (isset($element['#value']) && $element['#value'] !== '' && !user_load_by_name($element['#value'])) {
+    form_error($element, t('The username %name does not exist.', array('%name' => $element['#value'])));
+  }
+}
+
+/**
  * Generate a random alphanumeric password.
  */
 function user_password($length = 10) {
