josiasmontag / laravel-recaptchav3

Laravel package for Google's Recaptcha V3
MIT License
188 stars 37 forks source link

Invalid action name #31

Closed jefsev closed 1 year ago

jefsev commented 1 year ago

No matter what i do i always get: Invalid action name, may only include "A-Za-z/_". Do not include user-specific information. And the form cannot be submitted.

It's rendered like this in the html

  grecaptcha.ready(function() {
      grecaptcha.execute('6LdC4jklAAAAAP7JF31jlY3AjXFEGtCxJxHZRjGf', {action: 'handle-form'}).then(function(token) {
         document.getElementById('g-recaptcha-response-64234447bb0d9').value = token;
      });
  });

Any idea what's going wrong?

bnp-aswin commented 1 year ago

try this grecaptcha.ready(function() { grecaptcha.execute('6LdC4jklAAAAAP7JF31jlY3AjXFEGtCxJxHZRjGf', {action: 'handleForm'}).then(function(token) { document.getElementById('g-recaptcha-response-64234447bb0d9').value = token; }); });

jefsev commented 1 year ago

Thanks, i fixed it.

After checking the recaptcha3 docs on google i realized that the {!! RecaptchaV3::field('register') !!} <-- i needed to update register to submit as my submit button is named submit. That fixed it for me.