【问题标题】:Semantic UI / Fomantic UI form validation with Google reCAPTCHA v3使用 Google reCAPTCHA v3 进行语义 UI / Fomantic UI 表单验证
【发布时间】:2021-04-13 21:57:02
【问题描述】:

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

【问题讨论】:

    标签: forms validation recaptcha semantic-ui fomantic-ui


    【解决方案1】:

    更新:我找到了方法。我将此来源用作初始参考:https://code.tutsplus.com/tutorials/example-of-how-to-add-google-recaptcha-v3-to-a-php-form--cms-33752。遵循使用语义 UI/Fomantic 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;
            }
        });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-31
      • 1970-01-01
      • 2014-11-26
      • 1970-01-01
      • 2016-08-23
      相关资源
      最近更新 更多