May 17, 2020: Fixed issue where multiple double-confirmations couldn't be used in the same form.
November 15, 2019: Updated demo URL.
Request users to confirm important information on your forms by entering it twice. Ya know, like the option on the email field? Here’s the code:
To install this snippet simply copy and paste the full code into your theme’s functions.php file. You can specify which fields should be confirmed and on which form(s) by using the register_confirmation_fields function.
The first parameter is the form ID. The second parameter is an array of field IDs whose values should match. You can register multiple sets of fields for confirmation by making a new call to the register_confirmation_fields function for each.
// register field IDs 1 and 2 on form ID 8 register_confirmation_fields( 8, array( 1, 2 ) ); // register field IDs 12 and 14 on form ID 2 register_confirmation_fields( 2, array( 12, 14 ) );
Beyond the Code
You may wish to better indicate a relationship between the two fields which will be confirmed against each other. One simple way to do this is to display the fields next to each other (like I’ve done in the demo). This is readily accomplished using Gravity Forms’ column layout. Use the column drop zones to display the columns side-by-side.
Let us know if you found this snippet useful and any suggestions for improvement!