【问题标题】:zend form with jquery mobile and recaptcha带有 jquery mobile 和 recaptcha 的 zend 表单
【发布时间】:2013-05-13 18:49:15
【问题描述】:

我在 jquery 移动应用程序中尝试将 reCaptcha 实现为 zend 表单时遇到了问题。当 jquery mobile 被禁用时,一切都很好,但我需要使用它,但我只能从 recaptcha + 验证消息中看到标签。

$recaptcha = new Zend_Service_ReCaptcha(
    '644443tQSAA4444444444444444444WNm6',
    '6L44443444444444444444444EmA_4448');

$captcha = new Zend_Form_Element_Captcha('challenge2',
    array(
        'captcha'        => 'ReCaptcha',
        'captchaOptions' => array(
            'captcha' => 'ReCaptcha', 
            'service' => $recaptcha
        )
    )
);

$captcha->setLabel('hello');        
$captcha->setErrorMessages(array( 'Please retape above words correctly'));
$this->addElement($captcha);

我试图 $captcha->setAttrib('data-role', 'none') 但没有帮助。
如何使用 Zend Framework 在 jQuery Mobile 上显示 reCaptcha?

【问题讨论】:

  • 你找到解决方案了吗?

标签: php zend-framework jquery-mobile recaptcha


【解决方案1】:

这里有关于如何处理的信息https://developers.google.com/recaptcha/docs/display?hl=en#AJAX

我所做的是将此脚本添加到布局中:

<script type="text/javascript" src="http://www.google.com/recaptcha/api/js/recaptcha_ajax.js"></script>

然后,在有验证码的页面上,我有以下代码:

$('[data-role=page]').on('pagebeforeshow', function (event, ui) {
    if ($('#recaptcha_widget_div').length<1) { //if it was not loaded earlier
        Recaptcha.create("<your key>", 'captcha-element', {
            lang : 'en',
            tabindex: 1,
            theme: "clean",
            callback: Recaptcha.focus_response_field
        });
    }
}

“captcha-element”是包装我的验证码元素的 div 的 id。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多