FriendlyCaptcha / friendly-challenge

The widget and docs for the proof of work challenge used in Friendly Captcha. Protect your websites and online services from spam and abuse with Friendly Captcha, a privacy-first anti-bot solution.
https://friendlycaptcha.com
MIT License
414 stars 61 forks source link

How can I make FriendlyCaptcha a required field? #104

Closed abidi12 closed 2 years ago

abidi12 commented 2 years ago

I'm using FriendlyCaptcha and have been able to add the CAPTCHA component to my page inside a form. But when I submit the form there's no validation taking place to check if the CAPTCHA has been solved.

`<!– Add the widget script –>

` How do I validate that the CAPTCHA component has been solved when submitting my form? Or, in other words, how do I make my CAPTCHA component required? (using javascript)
Fancy11111 commented 2 years ago

Hi @abidi12!

First of, did you use the Attribute API or the JS API to create your widget?

Depending on which you used, the way you can check the status of the widget differs.

For the Attribute API: You can use the data-callback attribute. Here you can define a method that is called when the widget finished solving the puzzle. The function can have one argument, were the solution will be passed.

For the JS API: There are multiple callbacks you can pass in the options when creating the widget: doneCallback, startedCallback, errorCallback. Here, the doneCallback will probably be the one you are using. Again, like in the Attribute API, the callback method can take one argument, which will be the solution.

These callbacks only send you the generated solutions. You still have to verify those found solutions in your backend, via our Verification API

I hope I could clear things up!

abidi12 commented 2 years ago

Hi @Fancy11111

`

` [https://i.ibb.co/drjz23q/Untitled.png](url) I put this code but it still doesn't work
gzuidhof commented 2 years ago

The most pragmatic approach is generally to enable the submit button of your form in the doneCallback or errorCallback, that way users won't accidentally submit without the widget done solving.