使用 Google reCAPTCHA v3 进行语义 UI / 语义 UI 表单验证

问题描述 投票:0回答:2

我正在尝试找到一种使用 Google reCAPTCHA v3 验证 Semantic UI / Fomantic UI 表单的方法。我在 Stack 上找到了使用 Google reCAPTCHA v2 进行验证的选项。但是,新形式的 V3 验证有所不同,并使用另一种形式的用户界面。

forms validation recaptcha semantic-ui fomantic-ui
2个回答
1
投票

更新:我找到了一种方法。我使用此来源作为初始参考:https://code.tutsplus.com/tutorials/example-of-how-to-add-google-recaptcha-v3-to-a-php-form--cms-33752 。使用 Semantic UI / Semantic UI 遵循验证形式。另一方面,要验证服务器上的数据,请按照前面的参考资料获取更多信息。

表格验证:

var formSelector = 'formSelector'; // Form selector

$('.ui.form')
    .form({
        onSuccess(event, fields){
            var action = 'action'; // Action 
            var googleSiteKey = 'googleSiteKey'; // Google Site Key 
            
            grecaptcha.ready(function() {
                grecaptcha.execute(googleSiteKey, {action: action}).then(function(token) {
                    $(formSelector).append('<input type="hidden" name="token" value="'+token+'">');
                    $(formSelector).append('<input type="hidden" name="action" value="'+action+'">');
                    $(formSelector).unbind('submit').submit();
                });
            });
            
            return false;
        }
    });

0
投票

Otavio,你可以发布你的表单验证代码吗?

© www.soinside.com 2019 - 2024. All rights reserved.