c10d-dev / craft-recaptcha

Integrate reCAPTCHA validation into your forms.
MIT License
2 stars 1 forks source link

Allow native HTML form validation on user registration forms #2

Closed mijewe closed 1 year ago

mijewe commented 1 year ago

Because the Recaptcha must be added using renderBindButton, which then submits the form with JS on the recaptchaBeforeSubmit callback, native HTML form validation is skipped.

I believe this can be achieved with something like

const form = document.getElementById("{{ options.button }}").closest("form");
if (form.reportValidity()) {
    form.submit();
}
c10d-dev commented 1 year ago

Hello, Thanks for this comment!

First, you don't have to use the renderSubmitButton or renderBindButton functions provided by the plugin, you can recreate the whole recaptcha setup by yourself in your templates.

However, I understand your point, and I'll check to integrate your solution in the coming weeks!

c10d-dev commented 1 year ago

Hello @mijewe!

It should work now on the v2.1.0, could you try and test it?

Thanks!