Add GotCHA to your website
Prerequisites
How to integrate GotCHA on your Website
2
Add GotCHA to your HTML Form
<form id="login">
<!-- Your existing form fields -->
<input type="text" name="username" placeholder="Username" />
<input type="password" name="password" placeholder="Password" />
<!-- Add the GotCHA widget here -->
<div
class="gotcha"
data-sitekey="YOUR_ACTUAL_SITE_KEY_HERE"
></div>
<br />
<input type="submit" value="Submit" />
</form><div
class="gotcha"
data-sitekey="E8DmBZote7dXw6p-e4h6LknEAs95bxkco8FKcuJxSJNCbk0NCRll9ERu7XDVwzhr"
></div>3
Handle Form Submission with JavaScript
<script>
document.getElementById("login").addEventListener("submit", function(e) {
e.preventDefault(); // Stop the form from submitting normally
// Get all form data including the GotCHA response
const formData = new FormData(e.target);
// The GotCHA token is automatically stored in 'gotcha-response'
const gotchaToken = formData.get("gotcha-response");
// Alternatively, use `gotcha` object from anywhere. Defaults to widgetId = 0
// const gotchaToken = gotcha.getResponse();
// Here's where you'd normally send the data to your server
// Example:
// fetch('/submit-form', {
// method: 'POST',
// body: formData
// });
});
</script>Last updated