i have an issue with Google Recaptcha V3. Id does work on single form but works only for first form if in page are more than 1 form.
How to make it work for all forms?
I know that issue is with id="recaptchaResponse"
but i have no ideas how to fix this! There are smilar questions ou there but could not found a solution.
Javascript:
<script src="https://www.google.com/recaptcha/api.js?render=key1"></script>
<script>
grecaptcha.ready(function () {
grecaptcha.execute('key2', { action: 'contact' }).then(function (token) {
var recaptchaResponse = document.getElementById('recaptchaResponse');
recaptchaResponse.value = token;
});
});
</script>
Forms:
<form class="user" action="" method="post" name="form1" id="form1">
<input type="hidden" name="source" value="form1">
<button type="submit" class="btn btn-success">Submit 1</button>
<input type="hidden" name="recaptcha_response" id="recaptchaResponse">
</form>
<form class="user" action="" method="post" name="form2" id="form2">
<input type="hidden" name="source" value="form2">
<button type="submit" class="btn btn-success">Submit 2</button>
<input type="hidden" name="recaptcha_response" id="recaptchaResponse">
</form>
Please help! Thanks in advance!