Turnstile Example #10360
Unanswered
MiraiTunga
asked this question in
Q&A
Turnstile Example
#10360
Replies: 2 comments 1 reply
-
Never used Turnstile before. Take a look at #1001; should be close enough, I believe. |
Beta Was this translation helpful? Give feedback.
0 replies
-
useForm register API essentially creates four properties for an input: const { onChange, onBlur, name, ref } = register('input-name'); You can register Turnstile input and then wire up the events manually: const {
register,
setValue
} = useForm();
// register manually
useEffect(() => {
register('cf-turnstile-response', {
required: 'Please verify you are human'
});
}, [register]);
// set Turnstile widget callback
// once captcha is solved, set token value and re-validate
widgetId = turnstile.render('#cf-turnstile', {
sitekey: siteKey,
callback: (token) => {
setValue('cf-turnstile-response', token, { shouldValidate: true });
}
}); |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am trying to use react-hook-forms with cloud flare https://developers.cloudflare.com/turnstile/
can someone help me with a full example ?
Beta Was this translation helpful? Give feedback.
All reactions