BrightLeaf Digital Code Snippet Library
Check out our growing library of code snippets for Gravity Forms!
Eleven of these snippets register their own shortcodes. Every tag and attribute is in our Gravity Forms shortcodes reference. Need a Gravity Forms or GravityView shortcode built for you? Try the free shortcode builder.
Prompt user to confirm radio selection before submitting form
Goal
This JavaScript snippet prompts users with a confirmation message before submitting a Gravity Form when they select a specific radio button choice. If the user selects a designated choice, a confirmation dialog appears, requiring them to confirm their selection before the form is submitted. This ensures that users intentionally proceed with their chosen option. Remember to update the choices and messages on the top of the snippet. And update the name of the radio button a few lines down. If you are unsure what the name is right click on the radio field, click inspect and you will be able to see the html element name.
Configuration
- Edit the config block below. Installed through GOCSM, these values are fields and survive snippet updates.
bldRadioFieldId: numeric field ID of the radio field (e.g., 3)bldRadioMessages: map of radio option value to confirmation messagebldRadioFormIds: optional array of form IDs; empty means apply to any form on the page
Features
- Prompts users with a confirmation message before submitting the form.
- Works specifically for radio button fields, allowing customized messages for each choice.
- Prevents accidental submissions by requiring user confirmation.
- Customizable messages for different radio button options.
- Lightweight and runs client-side for a seamless user experience.
This code is best installed directly on your form using the Code Chest plugin.
Loading...
Review this entry
You must be logged in to post a comment.