Recaptcha v3 on multipage forms

szablac 4d ago

Hi,

I have a form that consists of 3 pages. On submission of each page I have log data and save data actions, therefore I would like to apply Recaptcha v3 on each pages.

I can submit the first page. When I submit the second page, it keeps loading, nothing happens. In console, I can see an error message: TypeError: form.submit is not a function

The issue is in this part of the javascript code:

if (this._element.querySelector(".g-recaptcha.v3")) {   e.preventDefault();   let form = this._element;   grecaptcha.ready((function() {      grecaptcha.execute(form.querySelector(".g-recaptcha.v3").getAttribute("data-sitekey3"), {         action: "submit"      }).then((function(token) {         form.querySelector(".g-recaptcha.v3").remove(),         form.querySelector('[name="g-recaptcha-response"]').value = token,         form.submit()      }      ))  }  ))}

Could you help, please?

Thanks in advance.

Max_admin 4d ago
Answer

Keep captcha to first page only, does this fix it?

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
szablac 4d ago

Yes. If it is only on the first page, it works. But does this method secures data submission of the second and third pages as well?

Max_admin 3d ago

Users can not access later pages without accessing the first page (assuming the pages have the same Page Group value, which is the default).

So if the first page is secured then you should be ok

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Max_admin 3d ago

This also applies to the Log Data and Save Data actions, unless you need to make sure each step is saved in case the user quits early, it's better to save one time at the last page Submit event

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
szablac 1d ago
1 Likes

Thank you for your help, I will follow this advice.

You need to login to be able to post a reply.