admin管理员组

文章数量:1334937

I want to use Google ReCaptcha but i also dont't want to touch server side or back-end code.

I am using ASP.Net MVC but i also don't want to use any package from nuget or any library. Solution must be front-end only. All javascript/jquery solutions are accepted.

I also note that my forms are collecting data and sending it as an e-mail to specified mailbox. I am also not using any 3rd party library for this process. It is manually coded only by ASP.Net MVC.

I want to use Google ReCaptcha but i also dont't want to touch server side or back-end code.

I am using ASP.Net MVC but i also don't want to use any package from nuget or any library. Solution must be front-end only. All javascript/jquery solutions are accepted.

I also note that my forms are collecting data and sending it as an e-mail to specified mailbox. I am also not using any 3rd party library for this process. It is manually coded only by ASP.Net MVC.

Share Improve this question asked Jul 29, 2016 at 6:10 CromwellCromwell 5061 gold badge6 silver badges25 bronze badges 3
  • 1 use java script, grecaptcha.getResponse() – Rinto Antony Commented Jul 29, 2016 at 6:20
  • 6 The important part of a solution such as Google's Recaptcha is the munication with the server-side. This is because front-end code can easily be read, cracked or even outright replaced. Let's say you have captcha_challenge(), which returns true if the user manages to solve the captcha. Now I go into the source and replace your function with function captcha_challenge() { return true; }. I click the button again and I'm in. There's really no point in implementing something like a captcha or password encryption on the front-end only. You need a back-end for it to work securely. – Ivo Coumans Commented Jul 29, 2016 at 6:22
  • 1 Hello, according to Google remendation, a Google recaptcha has two steps. The first step is the UI integration. The second step is the back-end integration. Without the back-end integration, you would not have the total benefit of google recaptcha. – Hello Universe Commented Sep 9, 2018 at 23:58
Add a ment  | 

2 Answers 2

Reset to default 5

Thanks to Ivo Coumans for detailed explanation. I got it working but obvously it is not safe. Rinto Antony gave me an idea here is what i do.

I am calling the Google ReCaptcha API to head section of my website and adding the div that creates the captcha:

<div class="g-recaptcha" data-sitekey="api_key" data-callback="enableBtn"></div>

Since data-callback is triggering enableBtn function, it is possible to take action if it is returning true. So i have added a disabled submit button to my form.

<input type="submit" value="Gönder" id="button1" disabled>

Then i have added a simple javascript to enable it:

<script type="text/javascript">
    function enableBtn() {
    document.getElementById("button1").disabled = false;
}
</script>

I am aware that this can be easily bypassed and not a real solution but it is working. I am open to any ideas that can make this better.

Unless you are using a CMS , you will have to put some code in the backend since you will making a POST request with the reCAPTCHA.

I highly remend wordpress as it will be a matter of just downloading a plugin and then just copying the keys and pasting them.

本文标签: javascriptGoogle ReCaptcha FrontEnd SolutionStack Overflow