How to make autocomplete return nid and name?
Take a look at the examples module's ajax_example_autocomplete.inc file. You'll need to add a validation function that looks up the nid from the node->title:

  $result = preg_match('/\[([0-9]+)\]$/', $title, $matches);
  if ($result &gt; 0) {
    // If $result is nonzero, we found a match and can use it as the index into
    // $matches.
    $nid = $matches[$result];
    // Verify that it's a valid nid.
    $node = node_load($nid);
    if (empty($node)) {
      form_error($form['node'], t('Sorry, no node with nid %nid can be found', array('%nid' =&gt; $nid)));
      return;
    }
  }
  // BUT: Not everybody will have javascript turned on, or they might hit ESC
  // and not use the autocomplete values offered. In that case, we can attempt
  // to come up with a useful value. This is not absolutely necessary, and we
  // *could* just emit a form_error() as below.
  else {
    $nid = db_select('node')
      -&gt;fields('node', array('nid'))
      -&gt;condition('title', db_like($title) . '%', 'LIKE')
      -&gt;range(0, 1)
      -&gt;execute()
      -&gt;fetchField();
  }