2017-06-29 101 views
0

我在我的網站上有一個窗體,但我一直在收到一些跨度,所以我添加谷歌RecaptchaV2並停止跨度,但我想禁用提交按鈕,直到Recaptcha被選中並且用戶證明那是人類。RecaptchaV2啓用/禁用提交

RecaptchaV2在Iframe中運行,我如何讀取元素或屬性來禁用Submit?

的iframe中存在着改變的內容一旦被驗證跨度: 來自:

<span id="recaptcha-accessible-status">Recaptcha requires verification</span>

到:

<span id="recaptcha-accessible-status">You are verified</span> 

所以讀書,我想也許可以禁用/啓用用JQuery提交按鈕,嘗試使用content()來閱讀它,但無法訪問iframe的內容,有什麼想法?

謝謝!

+0

那你又試過這麼遠嗎? – vaso123

+0

我在帖子中加入了更多細節。 – ysanmiguel

+1

[我如何驗證谷歌reCAPTCHA V2使用javascript/jQuery?](https://stackoverflow.com/questions/27902539/how-can-i-validate-google-recaptcha-v2-using-javascript-jquery ) – vaso123

回答

0

這裏就是答案,這只是禁用/啓用提交檢查按鈕:

去到不同的形式在一個頁面上工作,但沒有測試過,有什麼建議/變化是值得歡迎的。

呼叫:

<div class="g-recaptcha" data-sitekey="KEY-HERE" data-callback="correctCaptcha"></div> 
<script type="text/javascript" src="https://www.google.com/recaptcha/api.js?hl=en"></script> 

數據回調= 「correctCaptcha」是主片。

JS:

$("form").each(function() { 
    $(this).find(':input[type="submit"]').prop('disabled', true); 
}); 
function correctCaptcha() { 
    $("form").each(function() { 
     $(this).find(':input[type="submit"]').prop('disabled', false); 
    }); 
}