diff --git a/entityreference.module b/entityreference.module
index bb66503..3e2e63f 100644
--- a/entityreference.module
+++ b/entityreference.module
@@ -183,9 +183,21 @@ function entityreference_field_validate($entity_type, $entity, $field, $instance
       $ids[$item['target_id']] = $delta;
     }
   }
-
+  // Check for invalid autocomplete input.
+  if (isset($instance['widget']['type']) && $instance['widget']['type'] == 'entityreference_autocomplete') {
+    foreach ($items as $delta => $item) {
+      // If the field is empty then drupal form validation has already flagged empty required fields.
+      // If it is null, then there is a value, but not a valid one. @see _entityreference_autocomplete_validate().
+      if (is_null($item['target_id'])) {
+        $errors[$field['field_name']][$langcode][$delta][] = array(
+          'error' => 'entityreference_invalid_entity',
+          'message' => t('@field field contains invalid @type.', array('@field' => $instance['label'], '@type' => $field['settings']['target_type'])),
+        );
+      }
+    }
+  }
+  // Check if the reference is valid.
   $valid_ids = entityreference_get_selection_handler($field, $instance)->validateReferencableEntities(array_keys($ids));
-
   $invalid_entities = array_diff_key($ids, array_flip($valid_ids));
   if ($invalid_entities) {
     foreach ($invalid_entities as $id => $delta) {
@@ -634,13 +646,50 @@ function entityreference_field_widget_form(&$form, &$form_state, $field, $instan
 }
 
 function _entityreference_autocomplete_validate($element, &$form_state, $form) {
-  // If a value was entered into the autocomplete...
   $value = '';
+  // If a value was entered into the autocomplete...
   if (!empty($element['#value'])) {
     // Take "label (entity id)', match the id from parenthesis.
     if (preg_match("/.+\((\d+)\)/", $element['#value'], $matches)) {
       $value = $matches[1];
     }
+    else {
+      // Try to get a match from the input string when the user didn't use the autocomplete
+      // but filled in a value manually.
+      $field_name = $element['#field_name'];
+      $field = field_info_field($field_name);
+      $handler = entityreference_get_handler($field);
+      $entities = $handler->getReferencableEntities($element['#value'], '=', 6);
+      if (!empty($entities)) {
+        if (count($entities) > 5) {
+          // Error if there are more than 5 matching entities.
+          form_error($element, t('Many entities are called %value. Specify the one you want by appending the id in parentheses, like "@value (@id)"',
+            array(
+              '%value' => $element['#value'],
+              '@value' => $element['#value'],
+              '@id' => key($entities),
+          )));
+        }
+        elseif (count($entities) > 1) {
+          // More helpful error if there are only a few matching entities.
+          $multiples = array();
+          foreach ($entities as $id => $name) {
+            $multiples[] = $name . ' (' . $id . ')';
+          }
+          form_error($element, t('Multiple entities match this reference: %multiple', array('%multiple' => implode(', ', $multiples))));
+        }
+        else {
+          // Take the one and only matching entity.
+          $value = key($entities);
+        }
+      }
+      else {
+        // No matching entities found.
+        // Set value to NULL rather than an empty string to distinguish this case
+        // in the hook_field_validate().
+        $value = NULL;
+      }
+    }
   }
 
   // Update the value of this element so the field can validate the product IDs.
