[英]recaptcha v3 form not submiting
我試圖通過延遲執行直到提交來避免recaptcha v3超時。 可悲的是,當我按下提交按鈕時,它什么也沒做。 這是我的代碼。
JAVASCRIPT
<script>
grecaptcha.ready(function() {
document.getElementById('contactForm').addEventListener("submit", function(event) {
event.preventDefault();
grecaptcha.execute('xxxxxx', {
action: 'homepage'
}).then(function(token) {
var recaptchaResponse = document.getElementById('recaptchaResponse');
recaptchaResponse.value = token;
document.getElementById('contactForm').submit();
});
}, false);
});
</script>
HTML
<form method="POST" action="<? echo $url . '/nueva/'; ?>" id="contactForm">
<div class="form-group row">
<label class="col-3 col-form-label" for="palabra">address</label>
<div class="col-9">
<input id="address" name="address" type="text" class="form-control here">
</div>
</div>
<div class="form-group row">
<div class="offset-3 col-9">
<button name="submit" type="submit" class="btn btn-primary btn-block">Enviar</button>
<input type="hidden" name="recaptcha_response" id="recaptchaResponse">
</div>
</div>
</form>
我猜是 php & javascript,我的代碼是 ASP.NET MVC & Z6A2D7208853DAFFCB96FB5A738
Javascript
grecaptcha.ready(function() {
document.getElementById('enviar').addEventListener("click", function(event) {
return new Promise((res, rej) => {
grecaptcha.ready(function () {
grecaptcha.execute('xxxxxx', { action: 'homepage' }).then(function (token) {
var recaptchaResponse = document.getElementById('recaptchaResponse');
recaptchaResponse.value = token;
});
});
});
}, false);
});
HTML
<button id="enviar" name="submit" type="submit" class="btn btn-primary btn-block">Enviar</button>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.