Atenção!

Este artigo contém código JavaScript e é destinado a desenvolvedores. Oferecemos este código como uma cortesia, mas não fornecemos suporte para personalizações de código ou desenvolvimento de terceiros.

Para orientação extra, consulte o tutorial do WPBeginner sobre como adicionar código personalizado.

Dispensar

Como Adicionar JavaScript a uma Página ao Usar o Addon de Páginas de Formulário

Looking to streamline your JavaScript integration for forms created with the Form Pages addon? We’ve got just the solution! Discover how to leverage a dedicated hook tailored specifically for pages featuring Form Pages forms. This separate hook ensures that your scripts are loaded only on pages containing these forms, preventing unnecessary script loading across your entire site and optimizing performance.

For more information regarding this type of form, please check out documentation on the Form Pages addon.

Setting Up Your form

For our tutorial, we want our Form Pages to display a little animation when the form submits. For detailed information, check out our guide on adding animation to confirmation messages.

So we’ll begin by creating our form and adding our canvas element to Confirmation message on the Text tab.

create your form and add your canvas element to the Text tab of the Confirmation message

For more information on what canvas is, please check out this article from W3Schools.

If you need any help in creatng your form, please check out our guide on creating your first form.

Adding the JavaScript to Form Pages

Now it’s time to add the snippet that contains the script we want to log on our Form Pages form.

Se precisar de ajuda para adicionar snippets ao seu site, consulte este tutorial.

add in javascript to forms created with form pages addon

You can use the wpforms_form_pages_footer action to call in any JavaScript from a scroll to top button, live chat service, or even just your Google analytics.

And that’s all you need! Next, would you like to count the entries for your form as they come in? Take a look at our article How to Increment a Count on Each Form Submission.

Ação de Referência

wpforms_form_pages_footer