要求用户在提交表单之前单击Google的新Recaptcha [英] Require User to click google's new recaptcha before form submission
问题描述
我在表单(HTML5)中使用了Google的新Recaptcha: https://www.google.com/recaptcha
I am using google's new recaptcha inside my form (HTML5): https://www.google.com/recaptcha
在提交表单之前,是否可以根据需要检查并标记recaptcha? 我想在客户端而不是服务器端对此进行验证.这样,我不必返回表格并警告用户不要为验证码输入任何内容.
Is there a way to check and mark recaptcha as required before form submission? I want to validate this on client side instead of server side. That way, I don't have to go back to the form and warn user about not entering anything for the captcha.
我可以用来检查用户是否在Recaptcha中输入了任何JavaScript吗?
Any javascript that I can use to check whether user enter anything in recaptcha?
推荐答案
您可以检查ID为g-recaptcha-response
的textarea字段.您可以执行以下操作:
You can check the textarea field with id g-recaptcha-response
. You can do as following:
$("form").submit(function(event) {
var recaptcha = $("#g-recaptcha-response").val();
if (recaptcha === "") {
event.preventDefault();
alert("Please check the recaptcha");
}
});
希望这对您有所帮助.
这篇关于要求用户在提交表单之前单击Google的新Recaptcha的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!