How to add multiple Google reCAPTCHA in a Website
In this tutorial, we will discuss How to add multiple Google reCAPTCHA to a Website. we need to include multiple google reCAPTCHA’s on a single website in multiple forms. Generally, one Google reCAPTCHA on one page and use the token of the Google reCAPTCHA to verify. The most client required multiple Google reCAPTCHA use in single website multiple forms. So we will read in this tutorial How to add multiple Google reCAPTCHA to a Website.
Also read: How to integrate Google reCAPTCHA v3 in PHP
Example
<html>
<head>
<title>How to add multiple Google reCAPTCHA in a Website - devnote.in</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit"></script>
</head>
<body>
<h1>How to add multiple Google reCAPTCHA in a Website</h1>
<form id="MyForm" action='/add_post.php' method="post">
<h2>Example - 1</h2>
<input type="email" placeholder="Enter your email" size="40"><br><br>
<div id="g-recaptcha"></div><br><br>
<input type="submit" name="submit" value="Submit post">
</form>
<form id="MyForm" action='/add_post.php' method="post">
<h2>Example - 2</h2>
<input type="email" placeholder="Enter your email" size="40"><br><br>
<div id="g-recaptcha-2"></div><br><br>
<input type="submit" name="submit" value="Submit post">
</form>
</body>
<script>
function onloadCallback() {
if ( $('#g-recaptcha').length ) {
grecaptcha.render('g-recaptcha', {'sitekey' : 'past_your_site_key'});
}
if ( $('#g-recaptcha-2').length ) {
grecaptcha.render('g-recaptcha-2', {'sitekey' : 'past_your_site_key'});
}
}
</script>
</html>