Hi @-- -- ,
Based on your requirement, you can try to use its callback function to implement client-side validation and allow form submission based on this result. Simply refer to the following code samples:
Page code:
<div id="dvCaptcha">
</div>
<asp:TextBox ID="txtCaptcha" runat="server" Style="display: none" />
<asp:RequiredFieldValidator ID="rfvCaptcha" ErrorMessage="Captcha validation is required." ControlToValidate="txtCaptcha"
runat="server" ForeColor="Red" Display="Dynamic" />
<br />
<asp:Button ID="btnSubmit" Text="Submit" runat="server" />
VB.NET code:
Partial Class Default
Inherits System.Web.UI.Page
Protected Shared ReCaptcha_Key As String = "<RECaptcha Site Key>"
Protected Shared ReCaptcha_Secret As String = "<RECaptcha Secret Key>"
<WebMethod()> _
Public Shared Function VerifyCaptcha(response As String) As String
Dim url As String = "https://www.google.com/recaptcha/api/siteverify?secret=" & ReCaptcha_Secret & "&response=" & response
Return (New WebClient()).DownloadString(url)
End Function
End Class
Script code:
Best regards,
Xudong Peng
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.