2012-10-17 19 views
1

我有一個問題,試圖在jQuery的移動應用程序實現reCaptcha到zend形式。當jquery mobile被禁用時,一切都還好,但我需要使用它,但是我只能看到來自recaptcha +驗證消息的標籤。zend形式與jquery移動和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?

+0

您是否找到解決方案? –

回答

0

這對如何可以這樣處理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 
     }); 
    } 
} 

「驗證碼元」是圍繞我的驗證碼元的div ID。