diff --git a/entityreference.module b/entityreference.module
index f01ef7b..ae80585 100644
--- a/entityreference.module
+++ b/entityreference.module
@@ -467,6 +467,26 @@ function _entityreference_field_settings_process($form, $form_state) {
   $handler = entityreference_get_selection_handler($field, $instance);
   $form['handler']['handler_settings'] += $handler->settingsForm($field, $instance);
 
+  if ($form['target_type']['#default_value'] == 'taxonomy_term'){
+    $form['handler']['handler_settings'] += array(
+      'add_to_target' => array(
+        '#type' => 'checkbox',
+        '#title' => 'Create terms if no matches.',
+        '#default_value' => isset($settings['handler_settings']['add_to_target']) ? $settings['handler_settings']['add_to_target'] : 0,
+      )
+    );
+  }
+  else{
+    $form['handler']['handler_settings'] += array(
+      'add_to_target' => array(
+        '#type' => 'checkbox',
+        '#title' => 'Create terms if no matches.',
+        '#default_value' => 0,
+        '#disabled' => TRUE
+      )
+    );
+  }
+
   _entityreference_get_behavior_elements($form, $field, $instance, 'field');
   if (!empty($form['behaviors'])) {
     $form['behaviors'] += array(
@@ -903,6 +923,21 @@ function _entityreference_autocomplete_validate($element, &$form_state, $form) {
   form_set_value($element, $value, $form_state);
 }
 
+function _entityreference_autocomplete_add_to_target($vocabulary, $entity, &$target_id){
+  $term = new stdclass();
+  $vid = taxonomy_vocabulary_machine_name_load($vocabulary);
+  if($vid === FALSE){
+    // Error vocabulary does not exists.
+    form_error($element, t('There are is vocabulary matching "%value"', array('%value' => $vocabulary)));
+  }
+  $term->vid =  $vid->vid;
+  $term->name = $entity;
+  $res = taxonomy_term_save($term);
+  if($res == SAVED_NEW || $res == SAVED_UPDATE){
+    $target_id = $term->tid;
+  }
+}
+
 function _entityreference_autocomplete_tags_validate($element, &$form_state, $form) {
   $value = array();
   // If a value was entered into the autocomplete...
@@ -921,9 +956,19 @@ function _entityreference_autocomplete_tags_validate($element, &$form_state, $fo
         // autocomplete but filled in a value manually.
         $field = field_info_field($element['#field_name']);
         $handler = entityreference_get_selection_handler($field);
-        $value[] = array(
-          'target_id' => $handler->validateAutocompleteInput($entity, $element, $form_state, $form),
-        );
+        $target_id = $handler->validateAutocompleteInput($entity, $element, $form_state, $form);
+
+        // add_to_target check
+        $add_to_target = !empty($handler->field['settings']['handler_settings']['add_to_target']);
+
+        if (empty($target_id) && $add_to_target) {
+          $machine_name_v = reset($handler->field['settings']['handler_settings']['target_bundles']);
+          _entityreference_autocomplete_add_to_target($machine_name_v, $entity, $target_id);
+          $value[] = array('target_id' => $target_id);
+        }
+        else {
+          $value[] = array('target_id' => $target_id);
+        }
       }
     }
   }
diff --git a/plugins/selection/EntityReference_SelectionHandler_Generic.class.php b/plugins/selection/EntityReference_SelectionHandler_Generic.class.php
index 97d0174..c4083ae 100644
--- a/plugins/selection/EntityReference_SelectionHandler_Generic.class.php
+++ b/plugins/selection/EntityReference_SelectionHandler_Generic.class.php
@@ -208,35 +208,48 @@ class EntityReference_SelectionHandler_Generic implements EntityReference_Select
    * Implements EntityReferenceHandler::validateAutocompleteInput().
    */
   public function validateAutocompleteInput($input, &$element, &$form_state, $form) {
-      $entities = $this->getReferencableEntities($input, '=', 6);
-      if (empty($entities)) {
-        // Error if there are no entities available for a required field.
-        form_error($element, t('There are no entities matching "%value"', array('%value' => $input)));
-      }
-      elseif (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' => $input,
-          '@value' => $input,
-          '@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))));
+    $entities = array();
+    foreach ($this->getReferencableEntities($input, '=', 6) as $bundle => $elist) {
+      $entities = array_merge($entities, $elist);
+    }
+    $field = field_info_field($element['#field_name']);
+    $handler = entityreference_get_selection_handler($field);
+    $add_to_target = !empty($handler->field['settings']['handler_settings']['add_to_target']);
+
+    if (empty($entities)) {
+      if ($add_to_target) {
+        // We create the term so no error.
+        return $entities;
       }
       else {
-        // Take the one and only matching entity.
-        return key($entities);
+        // Error if there are no entities available and no entity creation for a required field.
+        form_error($element, t('There are no entities matching "%value"', array('%value' => $input)));
       }
+    }
+    elseif (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' => $input,
+        '@value' => $input,
+        '@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.
+      return ($field['settings']['target_type'] == 'taxonomy_term') ? key(reset($entities)) : key($entities);
+    }
   }
 
   /**
-   * Build an EntityFieldQuery to get referencable entities.
+   * Build an EntityFieldQuery to get referenceable entities.
    */
   protected function buildEntityFieldQuery($match = NULL, $match_operator = 'CONTAINS') {
     $query = new EntityFieldQuery();
