【发布时间】:2015-03-10 06:02:37
【问题描述】:
我有一个简单的 aspx 联系表。 我想在提交表单之前验证 reCaptcha(客户端)。 请帮忙。
示例代码:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Test Form</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
<script>
$("#cmdSubmit").click(function () {
//need to validate the captcha
});
</script>
</head>
<body>
<form id="form1" runat="server">
<label class="clsLabe">First Name<sup>*</sup></label><br />
<input type="text" id="txtFName" name="txtFName" class="clsInput" /><br />
<div class="g-recaptcha" data-sitekey="my_key"></div>
<img id="cmdSubmit" src="SubmitBtn.png" alt="Submit Form" style="cursor:pointer;" />
</form>
</body>
</html>
我想在点击cmdSubmit 时验证验证码。
请帮忙。
【问题讨论】:
-
到目前为止你做了什么?需要更多信息,这个问题太模糊了。
-
如果您不通过服务器端验证向 google 发送发布请求,您甚至可以不包含验证码。下面建议的客户端验证将由机器人通过。
-
验证验证码被点击客户端>做某事>验证recaptcha数据服务器端>做某事。
-
不要。验证验证码客户端正在违背其目的。所以你打算把你的密钥扔出窗外吗?
标签: javascript jquery asp.net google-api recaptcha