Run JavaScript When Forms Are Saved or Submitted in WordPress

Run custom JavaScript when a form is saved, submitted, or both.

  • Run on save Trigger JavaScript when a form is saved.
  • Run on submit Trigger JavaScript when a form is submitted.
  • Run on both Choose to run the action on save and submit.
  • Custom JavaScript Enter your own JavaScript in the editor.
  • Use WS Form variables Include WS Form variables in your JavaScript.
  • Action sidebar setup Add and configure the action from the form Actions sidebar.

Use the Run JavaScript action to run JavaScript when a form is saved or submitted. This gives you a direct way to add custom behavior to your forms in WordPress.

You can choose when the action runs: on save, on submit, or both. Enter your JavaScript in the action editor and save your changes in the sidebar.

The JavaScript can include straight text or WS Form variables. For example, you can output submitted values inside your script.

  • Flexible trigger timing

    Choose whether your JavaScript runs when the form is saved, submitted, or both.

  • Built into Actions

    Add JavaScript from the Actions area while editing your form.

  • Editor-based input

    Enter the JavaScript you want to run directly in the action settings.

  • Variable support

    Use WS Form variables inside your JavaScript when needed.

  • Plain text supported

    The JavaScript field can include straight text as part of your script.

  • Works on form events

    Attach custom JavaScript to key form events without leaving the form builder.

  • Simple to add

    Create a new action, select JavaScript, and configure the settings that appear.

  • Save or cancel changes

    Like other WS Form sidebars, you can save your changes or cancel them.

Real Customer Reviews

Trusted by thousands of WordPress professionals.

  • I’ve tested many different form plugins and WS Form is really one of the best. The core feature set is very robust and the support is incredible.

    hellojosh
  • Incredibly easy to pair with your custom field provider compared to other form plugins. Mark is super responsive, listens to user requests, and releases well-thought-out features quickly.

    ramnathk
  • I’ve used several form plugins for WordPress but WS Form is by far my favorite. Its features are way more advanced than the other popular ones and the customer support has been great so far. I highly recommend it for those with more complex needs.

    Jon Lewis

Frequently Asked Questions

What does the Run JavaScript action do?

It allows you to run JavaScript when a form is saved or submitted.

When can the Run JavaScript action run?

You can choose to run it when the form is saved, submitted, or both.

Can I use WS Form variables in the JavaScript?

Yes. You can enter straight text or use a WS Form variable in the JavaScript.

Where do I enter the JavaScript?

Enter the JavaScript you would like to run in the editor in the action settings.

How do I run JavaScript on save or submit in WS Form?

When editing your form, click the Actions icon at the top of the page, add a new action, select JavaScript from the Action pulldown, configure the settings, and save your changes. You can also learn more here: Run JavaScript.