title: Get reCaptcha value via javascript?
body: <p>I've added reCaptcha to my site, and when I use it normally in a form everything works great, but now I faced a problem when I tried to read the captcha value via JavaScript or jQuery. I have this HTML code that loads reCaptcha on my page.</p>
  
  <pre><code>&lt;div align="center"&gt;
      &lt;script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=mySecretkey321"&gt;&lt;/script&gt;
      &lt;noscript&gt;
          &lt;iframe src="http://www.google.com/recaptcha/api/noscript?k=mySecretkey321" height="300" width="500" frameborder="0"&gt;&lt;/iframe&gt;&lt;br&gt;
          &lt;textarea id="rcf" name="recaptcha_challenge_field" rows="3" cols="40"&gt;&lt;/textarea&gt;
          &lt;input type="hidden" id="rrf" name="recaptcha_response_field" value="manual_challenge"&gt;
      &lt;/noscript&gt;
      &lt;input type="button" value="Ok!" id="ok" class="btn btn-danger btn-lg"/&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>When I fill in the captcha field and click on a button I want to load the values of <strong>recaptcha_response_field</strong> and <strong>recaptcha_challenge_field</strong> so I can submit them via $.get(); so I've come up with this code:</p>
  
  <pre><code>$("#ok").click(function() {
      var res,res2;
      var rcf = document.getElementsByName('recaptcha_challenge_field').value;
      var rrf = document.getElementsByName('recaptcha_response_field').value;
      var url = "go.php?rcf="+ rcf +"&amp;rrf=" + rrf;
      alert(url);
      $.get( url, function( data ) {
        var n = data.indexOf("#");
        res = data.slice(0,n);
        res2 = data.slice(n+1);
      });
  });
  </code></pre>
  
  <p>When I click the button I get an alert box with this value:</p>
  
  <pre><code>go.php?rcf=undefined&amp;rrf=undefined
  </code></pre>
  
  <p>Basically I can't read those fields and I think that I'm reading the wrong ones. File go.php verifies captcha I just need to pass those two captcha fields to it so it can do all the background work of checking the captcha.</p>
  
  <p>I really don't know how to achieve this and I guess there is a simple solution, but I couldn't find it anywhere so I wanted to ask the community.</p>
  
  <p>Best Regards!</p>