Gravity Forms + Custom JavaScript
Need to update form data or provide feedback to users based on their interaction with your form before the form is submitted? Adding custom JavaScript might just be the solution to your problem! In this tutorial, I’ll show you how to add custom JavaScript to your Gravity Forms forms in WordPress using the Code Chest add-on from Gravity Wiz.
This is not the only way to add JavaScript to your forms built with Gravity Forms, but it is a nice way to have the code live in your WordPress database associated with the form so that the code travels with the form when you duplicate or export/import the form between sites.
Something important to note that I failed to do in the video is that there may be times when you’ll want to validate the data in PHP after the form is submitted to ensure that the script or form values weren’t altered by the user prior to submission. This is especially important if building something that is calculating a price and accepting payment in a more complex way than provided by Gravity Forms without additional scripting. Here’s an example in the Gravity Forms documentation.