reCaptcha Not Working

709 views
Skip to first unread message

Craig Velardi

unread,
Jan 4, 2017, 5:36:22 AM1/4/17
to reCAPTCHA
I put the requested code before </head> and put the additional site key coding within the <form></form> and the recaptcha does show a box with just a check box but no pictures. The form can be submitted without using the recaptcha. What am I missing?

Sven Klingenberg

unread,
Jan 9, 2017, 6:34:21 AM1/9/17
to reCAPTCHA
I have the sam Problem - can anyone help, please ?

Jack Yasgar

unread,
Jan 14, 2017, 1:14:41 PM1/14/17
to reCAPTCHA
reCAPTCHA does not stop a submission automatically, you still have to write code to send and validate the response from google. If you're using .NET ASPX or MVC I can help you, if not you'll have to search the web for examples.

Thanks, Jack

Jack Yasgar

unread,
Jan 15, 2017, 10:49:50 AM1/15/17
to reCAPTCHA
I'll go through the steps, just for clarity:

1. Register your domain at https://www.google.com/recaptcha to get your Site and Private (Secret) key
2. Place the script on your page, as close to the top as possible:
   a. <script src="https://www.google.com/recaptcha/api.js" async defer></script>
3. Place the widget on your page, within your form tags:
   a. <div class="g-recaptcha" data-sitekey="your_site_key"></div>
4. On your post-back event, in other words, the code that is executed when the user clicks the submit button, you need to get the response from the widget
   a. Sample: var response = Request.Form["g-Recaptcha-Response"];
5. Call to google to see if the user passed the test, note this is .NET C# code:
   a. 
            string secret = "Your_Private/Secret_Key";

            var client = new WebClient();
            var reply =
                client.DownloadString(
                secret, response));

            CaptchaResponse captchaResponse = JsonConvert.DeserializeObject<CaptchaResponse>(reply);

            //when response is false check for the error message
            if (!captchaResponse.Success)
            { // this means failed }
            else
            { // this means they passed, let them continue }


The "CaptchaResponse" class above is simply a class I created that has two properties:

    public class CaptchaResponse
    {

        [JsonProperty("success")]
        public bool Success { get; set; }

        [JsonProperty("error-codes")]
        public List<string> ErrorCodes { get; set; }

    }

You can deserialize the response into anything you want. The reCAPTCHA is not going to stop submission automatically, as that would be way to intrusive. What if a developer wants to do something when they fail? Maybe you want to send an electric shock to their chair... :-)

Here is an example return from the siteverify call:

{
  "success": false,
  "challenge_ts": "2017-01-14T17:59:41Z",
  "hostname": "www.your_recaptcha_registered_domain.com"
}

My object only grabs the success and an error collection. As you can see, there are a few more properties that could be returned that I don't care about.

I hope this helps.

Thanks, Jack

Craig Velardi

unread,
Jan 15, 2017, 11:17:19 AM1/15/17
to reCAPTCHA
Thank you Jack, I will look this over and get back to you with any questions, which I'm sure I will have as I'm not too familiar with .NET, etc.

What I did do in the mean time, especially since I had the same individual bombarding me with multiple emails from my site daily, was to create a hack that allowed me to capture his/her IP address and have it sent back to me when I received the spams. This was difficult to do since I was using a site form, but it worked and I blocked the IP address never again to receive spam from whomever it was. This is what I used in the form:

<input TYPE="hidden" value="<!--#echo var="REMOTE_ADDR"-->" name="IP address" size="40" MAXLENGTH="15"><!--#echo var="REMOTE_ADDR"-->

The above allows the persons IP address to appear and also send back to me without the sender being able to change or delete their IP address. This has allowed me to be able to block the IP address eliminating spam from that user.

Jack Yasgar

unread,
Jan 15, 2017, 7:21:53 PM1/15/17
to reCAPTCHA
Is your site HTML only?

Craig Velardi

unread,
Jan 16, 2017, 7:27:43 AM1/16/17
to reCAPTCHA
Yes, HTML only.

Jack Yasgar

unread,
Jan 16, 2017, 12:51:31 PM1/16/17
to reCAPTCHA
Hi Craig,

In between posts, I've written a few blog posts about reCAPTCHA. Take a look when you have a chance. I hope they'll help you.

Google reCAPTCHA in HTML / JavaScript



Thanks, Jack



On Monday, January 16, 2017 at 7:27:43 AM UTC-5, Craig Velardi wrote:
Yes, HTML only.

Craig Velardi

unread,
Jan 18, 2017, 12:29:15 PM1/18/17
to reCAPTCHA
Jack - Thank you!

I appreciate all that you've done.

I'll look over the information you've supplied via the links provided.

Thanks again ...

Craig
Reply all
Reply to author
Forward
0 new messages