Hidden Mode
Using the hidden mode you can integrate CaptchaFox without explicitly showing the widget inside your form.
When the user clicks on the submit button, you start the verification with the captchafox.execute API.
If the behavior of your site requires a visual challenge, it is displayed to the user at that moment.
Update the container element
Set data-mode="hidden" on the container element:
<div class="captchafox" data-sitekey="YOUR_SITEKEY" data-mode="hidden"></div>Execute the verification
Call captchafox.execute() when the form is submitted. It returns a Promise that resolves with the response token,
which you then send to your server for verification.
See captchafox.execute for details.
Example:
<html>
<head>
<title>CaptchaFox Demo</title>
<script async defer src="https://cdn.captchafox.com/api.js"></script>
</head>
<body>
<form id="login-form" action="YOUR_SERVER_ENDPOINT" method="POST" onsubmit="submitForm(event)">
<input type="text" name="email" placeholder="Email" />
<input type="password" name="password" placeholder="Password" />
<div class="captchafox" data-sitekey="YOUR_SITEKEY" data-mode="hidden"></div>
<button type="submit">Submit</button>
</form>
<script>
async function submitForm(event) {
event.preventDefault();
try {
await captchafox.execute();
// The token was added to the form as `cf-captcha-response`. Submit it to your server.
document.getElementById('login-form').submit();
} catch (error) {
console.error(error);
}
}
</script>
</body>
</html>Privacy notice
Since there is no visible widget, add a notice to the page:
In order to comply with the online privacy laws please add the following text and links to the page when using hidden mode:
This site is protected by CaptchaFox and its
<a href="https://captchafox.com/privacy">Privacy Policy</a> and
<a href="https://captchafox.com/terms">Terms of Service</a> apply.Please note that this is not legal advice.