/*************************************************************/ /* recaptcha API /* 參考 https://developers.google.com/recaptcha/docs/display /*************************************************************/ var verifyCallback = function(response) { // 如果 JavaScript 驗證成功 if (response) { $.post('./lib/captcha.php', { 'g-recaptcha-response': response }, function(data, status) { // 如果 PHP 驗證成功 if (status == 'success') console.log('驗證成功'); else console.log('驗證失敗'); }); } }; var siteKey = $("#my-recaptcha").attr("sitekey"); var onloadCallback = function() { grecaptcha.render( 'my-recaptcha', { // widget 驗證碼視窗在 id="my-widget" 顯示 'sitekey' : siteKey, // API Key 'callback' : verifyCallback, // 要呼叫的回調函式 'theme' : 'dark' // 主題 } ); }; $(function(){ }).on({ change : function(){ var acc = $("#account").val(); var pwd = $("#password").val(); var lang = $(this).val(); if(!acc && !pwd) { location.href = './index.php?lang='+lang; } } },'#chose-lang');