2016-12-22 8 views

答えて

0

以下のGoogle reCaptcha検証の検証を使用してください。

スクリプト:

$(document).ready(function() { 
    $('.ui.form').form({ 
     recaptcha: { 
      identifier: 'g-recaptcha-response', 
      rules: [ 
       { 
        type: 'empty', 
        prompt: 'Please complete reCaptcha validation.' 
       } 
      ] 
     } 
    }, 
    { 
     onSuccess: function (event, fields) { 
      console.log('Success:', fields); 
      return false; 
      //event.preventDefault(); 
     }, 
     onFailure: function (error) { 
      console.log('Failure',error); 
      return false; 
     } 
    }); 
}); 

HTML:Arpitの答えに拡大すること

<!DOCTYPE html> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
     <title>Self Registration Module</title> 
     <meta charset="utf-8" /> 
     <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> 
     <script src="../../Content/Scripts/jquery.min.js"></script> <!-- version 3.0.0 -> 
     <script src="../../Content/semantic/semantic.min.js"></script> 
     <link href="../../Content/semantic/semantic.min.css" type="text/css" rel="stylesheet" class="ui" /> 
     <script src="https://www.google.com/recaptcha/api.js?onload=vcRecaptchaApiLoaded&render=explicit" async defer></script> 
    </head> 
    <body ng-app="registrationApp"> 
     <div class="ui container" lang="en" 
      <div class="ui attached message"> 
       <div class="header"> 
       Registation Form 
       </div> 
       <p>Fill out the form below to register user in rev</p> 
      </div> 
      <form class="ui form attached segment"> 
       <div class="field"> 
        <div vc-recaptcha 
         key="'6Lf4ax0UAAAAADWkffMAXBsFzx2dgkMMnqvw4tIE'" 
         ng-model="RecaptchaResponse"> 
        </div> 
       </div> 
       </div> 
      </form> 
     </div> 
    </body> 
</html> 
0

:ここ

は私

カスタム検証のために働いていた非アンギュラソリューションですあなたのフィールドの上のルールvalidatio N:

$.fn.form.settings.rules.recaptchaValidate = function() { 
    return (recaptchaVerified); 
}; 

があなたの検証にこれを追加します。

recaptcha: { 
    identifier: 'recaptcha', 
    rules: [ 
    { 
     type: 'recaptchaValidate', 
     prompt: 'Please complete reCaptcha validation.' 
    } 
    ] 
} 

とあなたのHTML:

<div class="required field"> 
    <div class="g-recaptcha" data-sitekey="{your key here}" data-callback="correctCaptcha"></div> 
    <input type="hidden" name="recaptcha" id="recaptch-validation"> 
</div> 

[ ... then this just before closing body tag ... ] 

<script type="text/javascript"> 
    var recaptchaVerified = false; 
    var correctCaptcha = function(response) { 
    recaptchaVerified = true; 
    }; 
    var expiredCaptcha = function() { 
    recaptchaVerified = false; 
    }; 
</script> 
関連する問題