Disable the submit button after first click

By: Ivan Lumina | Asked: 07/04/2024
ForumsCategory: Code HelpDisable the submit button after first click
Ivan Lumina asked 3 weeks ago

Hey. Hope you are fine.

I already created same topic on wordress.com(https://wordpress.org/support/topic/disable-the-submit-button-after-first-click/), but Jonathan Martínez(I believe the developer of this plugin) recommended to me to post it here.

Could you help me with disabling the submit button after pressing it first time? Right now if a user presses on it more than once the action repeats and it spoils Google reCaptcha ID, it become invalid.

So, the only option I see here is set it disable after pressing on it. But I know that the form is having some kind js validations and it can don’t pass it. So, how can I enable it back if such thing happened?

Maybe there is some event that I could use to enable and disable the submit button?

 

Best regards,
Ivan.      

1 Answers
Rob LeVineRob LeVine answered 2 weeks ago
Likely what you'll need to do is use JavaScript to put a listener on the submit button and when clicked, do what you need to do and then stop the propagation of the event so that Formidable doesn't handle it. If need be, you can always call submit on the form element yourself. If you need help with this I suggest reaching out to a coder here.
Ivan Lumina replied 2 weeks ago

Hi @Rob LeVine.

Thank you for your attention. Unfortunatelly I see that forms are doing some verifications before submit, and in some cases it can show some error instead of submit it. So I cannot just disable this button, because a user won't send it anymore. The only option I see here is try to catch some events that after a user submit button, like - verification start, verification end, submitting start.
I found out that forms get a class "frm_loading_form" during this event, so maybe I could try to check this if this class exists.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right