将 recaptcha(具有自定义外观)与 asp.net 集成

发布于 2024-08-30 06:17:50 字数 1648 浏览 3 评论 0原文

我使用 asp.net/c# weborms。我已将验证码添加到表单中并使用了他们网站上的内容。它需要自定义外观,因此如下所示:

<div id="recaptcha_widget" style="display:none">

   <div id="recaptcha_image"></div>
   <div class="recaptcha_only_if_incorrect_sol" style="color:red">Incorrect please try again</div>

   <span class="recaptcha_only_if_image">Enter the words above:</span>
   <span class="recaptcha_only_if_audio">Enter the numbers you hear:</span>

   <input type="text" id="recaptcha_response_field" name="recaptcha_response_field" />

   <div><a href="javascript:Recaptcha.reload()">Get another CAPTCHA</a></div>
   <div class="recaptcha_only_if_image"><a href="javascript:Recaptcha.switch_type('audio')">Get an audio CAPTCHA</a></div>
   <div class="recaptcha_only_if_audio"><a href="javascript:Recaptcha.switch_type('image')">Get an image CAPTCHA</a></div>

   <div><a href="javascript:Recaptcha.showhelp()">Help</a></div>

 </div>

 <script type="text/javascript"
    src="http://api.recaptcha.net/challenge?k=your_public_key">
 </script>
 <noscript>
   <iframe src="http://api.recaptcha.net/noscript?k=your_public_key"
        height="300" width="500" frameborder="0"></iframe><br>
   <textarea name="recaptcha_challenge_field" rows="3" cols="40">
   </textarea>
   <input type="hidden" name="recaptcha_response_field"
        value="manual_challenge">
 </noscript>

我需要在表单后面的代码中的button_click方法中做什么来检查用户输入的单词是否正确。音频也一样。

谢谢

Im using asp.net/c# weborms. I've added recaptcha to the form and used what is on their site. It needs a custom look hence it's like this:

<div id="recaptcha_widget" style="display:none">

   <div id="recaptcha_image"></div>
   <div class="recaptcha_only_if_incorrect_sol" style="color:red">Incorrect please try again</div>

   <span class="recaptcha_only_if_image">Enter the words above:</span>
   <span class="recaptcha_only_if_audio">Enter the numbers you hear:</span>

   <input type="text" id="recaptcha_response_field" name="recaptcha_response_field" />

   <div><a href="javascript:Recaptcha.reload()">Get another CAPTCHA</a></div>
   <div class="recaptcha_only_if_image"><a href="javascript:Recaptcha.switch_type('audio')">Get an audio CAPTCHA</a></div>
   <div class="recaptcha_only_if_audio"><a href="javascript:Recaptcha.switch_type('image')">Get an image CAPTCHA</a></div>

   <div><a href="javascript:Recaptcha.showhelp()">Help</a></div>

 </div>

 <script type="text/javascript"
    src="http://api.recaptcha.net/challenge?k=your_public_key">
 </script>
 <noscript>
   <iframe src="http://api.recaptcha.net/noscript?k=your_public_key"
        height="300" width="500" frameborder="0"></iframe><br>
   <textarea name="recaptcha_challenge_field" rows="3" cols="40">
   </textarea>
   <input type="hidden" name="recaptcha_response_field"
        value="manual_challenge">
 </noscript>

what do i need to do in the button_click method in the code behind iof the form to check if the words eneterd by the user is correct. same for audio.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

狼性发作 2024-09-06 06:17:50

为什么不使用 reCaptcha 提供的控件?这是控件和快速入门。

reCaptcha 快速入门 &控制

Why don't you use the control that is delivered with reCaptcha? Here is the control and a quickstart.

reCaptcha Quickstart & Control

弱骨蛰伏 2024-09-06 06:17:50

与其他验证一样,您只需要检查后面代码中的 if(Page.IsValid) 即可。请注意,您必须在代码中添加验证码控件,然后添加您的自定义控件。

<recaptcha:RecaptchaControl ID="recaptcha" runat="server" PublicKey="your_public_key"
PrivateKey="Your_private_key" Theme="custom" />
<div id="recaptcha_widget" style="display:none">
<div id="recaptcha_image"></div>
<div class="recaptcha_only_if_incorrect_sol" style="color:red">Incorrect please try again</div>
...

Like other validations you just need to check if(Page.IsValid) in behind code. just note that you have to add recaptcha control in your code and then add your customs them.

<recaptcha:RecaptchaControl ID="recaptcha" runat="server" PublicKey="your_public_key"
PrivateKey="Your_private_key" Theme="custom" />
<div id="recaptcha_widget" style="display:none">
<div id="recaptcha_image"></div>
<div class="recaptcha_only_if_incorrect_sol" style="color:red">Incorrect please try again</div>
...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文