diff --git a/recaptcha.js b/recaptcha.js
index 58168ab..ec4c030 100644
--- a/recaptcha.js
+++ b/recaptcha.js
@@ -1,7 +1,29 @@
 (function ($) {
   Drupal.behaviors.recaptcha = {
     attach: function (context) {
-      $(document).ready(Recaptcha.create(Drupal.settings.recaptcha.public_key, Drupal.settings.recaptcha.container, {theme: Drupal.settings.recaptcha.theme}));
+      Recaptcha.create(Drupal.settings.recaptcha.public_key, Drupal.settings.recaptcha.containers[0], {theme: Drupal.settings.recaptcha.theme});
+      Drupal.settings.recaptcha.current_container = 0;
+      Drupal.settings.recaptcha.form_map = new Array();
+      for (var i = 0, j = Drupal.settings.recaptcha.containers.length; i < j; i++) {
+        var form = $('#' + Drupal.settings.recaptcha.containers[i]).parents('form');
+        Drupal.settings.recaptcha.form_map[$(form[0]).attr('id')] = i;
+        var children = $(form).find(':input');
+        if (i > 0) {
+          $(form).find('.captcha').hide();
+        }
+        $(children).focus(function() {
+          var form = $(this).parents('form');
+          var form_id = $(form[0]).attr('id');
+          var container_id = Drupal.settings.recaptcha.form_map[form_id];
+          if (container_id != Drupal.settings.recaptcha.current_container) {
+            Recaptcha.destroy();
+            $('.captcha').hide();
+            $(form).find('.captcha').show();
+            Recaptcha.create(Drupal.settings.recaptcha.public_key, Drupal.settings.recaptcha.containers[container_id], {theme: Drupal.settings.recaptcha.theme});
+            Drupal.settings.recaptcha.current_container = container_id;
+          }
+        });
+      }
     },
     detach: function (context) {}
   };
diff --git a/recaptcha.module b/recaptcha.module
index cb2a44d..8136df3 100644
--- a/recaptcha.module
+++ b/recaptcha.module
@@ -61,11 +61,26 @@ function recaptcha_permission() {
 }
 
 /**
+ * Implements hook_js_alter().
+ */
+function recaptcha_js_alter(&$javascript) {
+  $containers = &drupal_static('recaptcha_captcha_containers', array());
+  foreach ($javascript['settings']['data'] as $js_key => $values) {
+    if (isset($values['recaptcha'])) {
+      $javascript['settings']['data'][$js_key]['recaptcha']['containers'] = $containers;
+      return;
+    }
+  }
+}
+
+/**
  * Implements hook_captcha().
  */
 function recaptcha_captcha() {
   $args = func_get_args();
   $op = array_shift($args);
+  $containers = &drupal_static('recaptcha_captcha_containers', array());
+  $current_counter = count($containers);
   switch ($op) {
     case 'list':
       return array('reCAPTCHA');
@@ -155,11 +170,12 @@ function recaptcha_captcha() {
             // Create the destination container, inserting any custom theme HTML
             // necessary ($recaptcha_custom_html will be empty if we are not
             // using custom theme).
-            '#markup' => '<div id="recaptcha_ajax_api_container">' . $recaptcha_custom_html . '</div>',
+            '#markup' => '<div id="recaptcha_ajax_api_container_' . $current_counter . '">' . $recaptcha_custom_html . '</div>',
           );
           drupal_add_js('https://www.google.com/recaptcha/api/js/recaptcha_ajax.js', array('type' => 'external'));
           $recaptcha_options['public_key'] = $recaptcha_public_key;
-          $recaptcha_options['container'] = 'recaptcha_ajax_api_container';
+          $recaptcha_options['container'] = "recaptcha_ajax_api_container_{$current_counter}";
+          $containers[] = "recaptcha_ajax_api_container_{$current_counter}";
           drupal_add_js(array('recaptcha' => $recaptcha_options), 'setting');
           drupal_add_js(drupal_get_path('module', 'recaptcha') . '/recaptcha.js');
         }
