【问题标题】:SurveyJS : How to implement captcha image challengeSurveyJS:如何实现验证码图像挑战
【发布时间】:2019-10-24 02:15:27
【问题描述】:

我尝试实现自定义小部件遵循指南https://surveyjs.io/Examples/Library/?id=custom-widget-select2-tagbox 但不显示验证码的图像挑战

我怎样才能为surveyjs表单实现验证码图像挑战?

【问题讨论】:

标签: surveyjs


【解决方案1】:

我找到路了:

html:

{
  type: "html",
  name: "info",
  html: "<div id='g-recaptcha'></div> <div class='form-group g-recaptcha' data-callback='verifyCaptcha' data-sitekey='" + recaptchaClientKey + "'></div>"
}

ts、js

survey.onCompleting.add(function (sender, options) {
    debugger;
    var response = grecaptcha.getResponse();
    if (response.length == 0) {
        document.getElementById('g-recaptcha').innerHTML =
            '<span class="form-group text-danger validation-summary-errors" data-valmsg-summary="true"><ul><li>Google reCAPTCHA validation failed</li></ul ></span >';
        options.allowComplete = false;
    } else {
        options.allowComplete = true;
    }
});

@section Scripts{
    <script type="text/javascript" src="~/js/signup/survey_config.js"></script>
    <script src='https://www.google.com/recaptcha/api.js'></script>
    <script>
        function verifyCaptcha() {
            document.getElementById('g-recaptcha').innerHTML = '';
        }
    </script>
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-10-14
    • 1970-01-01
    • 2012-02-03
    • 1970-01-01
    • 1970-01-01
    • 2019-01-28
    • 2017-01-25
    • 2018-09-30
    相关资源
    最近更新 更多