如何解决Google reCAPCHA v2 iframe错误

时间:2018-09-12 12:31:06

标签: javascript php jquery html bootstrap-4

我将自己的网站命名为nisharg.tk,最近我以register的形式添加了reCAPCHA,但它显示了

之类的错误 未捕获的TypeError:无法读取null的属性'postMessageId'     在onPostMessage(iframe.js:1000)

请告诉我我做错了什么?

$('.recapcha_confirm').submit(function(event){
  var $captcha = $( '#recaptcha' ),
      response = grecaptcha.getResponse();
  
  if (response.length === 0) {
    alert('Please Complete reCAPTCHA');
    event.preventDefault();
    if( !$captcha.hasClass( "error" ) ){
      $captcha.addClass( "error" );
    }
  } else {
    $captcha.removeClass( "error" );
    alert('lol');
  }
});
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://www.google.com/recaptcha/api.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<form id="validation" class="needs-validation recapcha_confirm" action="login.php" method="post" name="required_capcha"> `
	<div class="form-group">
		<label for="user">Username</label>
		<input minlength="6" class="form-control" type="text" name="username" placeholder="Username" value="" required>
	</div>
	<div class="form-group">
		<label for="email">Email</label>
		<input class="form-control" type="email" name="email" placeholder="Email" required>
	</div>
	<label for="password">Password</label>
	<div class="input-group form-group">		    
	    <input name="password" type="password" class="form-control pass" placeholder="Enter Password" minlength="6" required>
	    <span class="input-group-append">
            <span class="btn btn-outline-primary rounded-0 check" style="border-color: #ced4da;">
                <span class="fa fa-eye"></span>
            </span>
        </span>
	</div>
	<div class="form-group">
	    <div class="g-recaptcha" data-sitekey="6Lde3W8UAAAAAHI0_mSucn8oj3v90FhnurnbrfTI"></div>

	<div class="form-group text-center mt-4">
		<button class="btn btn-primary reg_submit" type="submit" name="register" value="Register">Register</button>
	</div>
</form>

我不进行网站推广,并且在本地主机中遇到相同的问题。

0 个答案:

没有答案