Custom Field Confirmation

April 11, 2023: Updated to ignore fields hidden by conditional logic.

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!


  1. Arvind
    Arvind July 10, 2020 at 1:20 am

    Hi there. This snippet works great. I am not aware whether or not snippets are inherently designed to support conditional logic hence this question. For eg. If this snippet has been installed – i am not sure whether or not – its supposed to NOT throw the “values do not match” error if, any of the fields configured to match, are hidden by conditional logic. So therefore if one of the fields configured is hidden by conditional logic – then the developer intends that the matching should not take place. Thank you.

    1. Samuel Bassah
      Samuel Bassah Staff July 10, 2020 at 8:45 am

      Hi Arvind,

      This an excellent question. The snippet requires that both fields you’re matching are on the form when it’s submitted. If one of the fields is hidden with conditional logic, the snippet will throw the “Your values do not match error”. A workaround will be to hide both fields if you do not intend to do any matching and show a new field if you want to show any of the two fields. I hope this helps?

      But in case you require additional support for this snippet, you can drop us a line through our support page here.

  2. Arvind
    Arvind May 15, 2020 at 3:16 am

    This works perfectly. Thanks very much for this snippet. With all this work you have made any kind of software possible even for non-coders like me.

    I am no developer but there may be a small issue : In case 2 pairs of fields need to be matched which are on the same form, there may be a chance that the snippet may cross match those fields. Eg if the snippet has been configured like this : form 68 (fields 2 and 3) and Form 68 (fields 10 and 11): there is a possibility that fields 3 and 11 will be matched by the snippet resulting in an error message – which may need a look I guess

    Posted here so that you may be able to look at it whenever you get the time.


  3. Kevin Hogan
    Kevin Hogan November 21, 2019 at 12:50 pm


    I’ve gone through and followed the snippet troubleshooting as you recommended and am still getting the fatal error. I’ve since submitted a support request as I am Gravity Perks customer.

  4. Dakota
    Dakota November 14, 2019 at 11:24 pm

    The “demo” just redirects back to this page. I’ve attempted to follow the instructions available on this page but can’t quite seem to get it to work. I just want somebody to enter information into a field, and then have to re-enter it for validation. If anyone could assist, I would greatly appreciate it.

    1. David Smith
      David Smith Staff November 15, 2019 at 9:01 am

      Hi Dakota, I’ve fixed the demo URL. Once you’ve seen how this should work, let me know if you’re still having issues.

    2. Dakota
      Dakota November 18, 2019 at 6:58 pm

      Thanks David! I see the demo now, however the code still does not work for me. It causes a critical error on my local site. Unfortunately since it’s local, I can’t provide you a URL to view anything either. Could you reach out to me via the email address I provided (assuming you see that information) for additional assistance perhaps?

  5. Arvind
    Arvind September 27, 2019 at 6:07 am

    Hi there

    Thanks for all the great work you guys are doing. Will this work for Drop down fields?

    I tried using this snippet for drop down fields. Even when the values were the same it still threw the validation error. So Tried to use the other snippet of yours which provides for validating values of fields in two different forms but that didnt work either for my drop down fields. The drop down fields that I am using is the normal drop down field by gravity forms and the ‘User’ field drop down provided by gravity flow URL:


    1. David Smith
      David Smith Staff September 27, 2019 at 12:19 pm

      I would expect this to work with Drop Down fields. I’m less confident about Gravity Flow’s User Drop Down field. If you’re a Gravity Perks user, we’ll be happy to take a closer look via support.

  6. julie
    julie September 24, 2019 at 8:26 am

    Great plugin. It works as it should. Please consider adding to the interface to grab the values rather than having to SFTP and copy/paste code. This plugin raises the bar! Awesome work.

    1. David Smith
      David Smith Staff September 24, 2019 at 9:06 am

      Glad this worked well for you, Julie. We’re certainly interested in providing a UI for this at some point. ?

  7. Chris
    Chris July 10, 2019 at 4:12 pm

    Great job, but I am looking for how to modify this code from gravity form, is a code to check if current user password match. But I want it to perform meta value check rather than password check… Any one can help me modify the below code.

    1. Current User Password validation

    add_filter( ‘gform_field_validation_10_2’, ‘check_current_password’, 10, 4 ); function check_current_password( $result, $value, $form, $field ) {

    $user = wp_get_current_user();
    if ( ! wp_check_password( $value, $user->data->user_pass, $user->ID ) ) {
      $result['is_valid'] = false;
      $result['message'] = 'Invalid current password. Please try again.';
    return $result;


  8. Mike
    Mike June 30, 2019 at 5:49 pm

    Hey, thanks for the snippet! Do you know if it’s possible to validate based on a given class instead of the field ID’s? ie. check if two fields have a certain class, and check if the value of those two fields matches.

    I have a case where there are multiples of the two fields I need to match, each pair displaying based on a conditional.



    1. David Smith
      David Smith Staff July 1, 2019 at 6:28 pm

      It is possible but this snippet does not support it. I’d recommend using this snippet as a base and having a service like add support for class-based designations.

    2. Mike
      Mike July 7, 2019 at 7:32 pm

      Budget’s not that high, unfortunately, but if I know it’s possible, I’ll head down the rabbit hole. Cheers David.

  9. Usman Butt
    Usman Butt April 30, 2019 at 8:59 pm

    Would this code work within list field? What would be the code for that?

    i.e If I add an email column inside the list and want to confirm the email by adding another column?

    1. David Smith
      David Smith Staff May 1, 2019 at 9:39 am

      Hey Usman, responded to your ticket but also clarifying here. This snippet only works field to field. It does not work with specific cells of a List field.

  10. TT
    TT February 5, 2018 at 1:21 pm

    Very useful code, thanks for sharing. I was wondering if there is a way modify the code to enable real-time validation. Instead of having to click the submit button to validate, that it would validate when the user clicks outside of the field.

    1. David Smith
      David Smith Staff March 8, 2016 at 10:54 pm

      For now, just modify the string directly in the snippet. If this snippet continues to be popular, I’ll update it so you can modify the string as a parameter.

  11. John Louis Geiger
    John Louis Geiger January 21, 2015 at 10:55 am

    If you do two sets of confirmation fields on the same form it is duplicating the last field and dropping the following existing field. Strange

    1. David Smith
      David Smith Staff August 4, 2015 at 7:39 pm

      Hi John, your comment was lost. Sorry about that. Could you send me an export of your form (if you’re still interested in this issue)?

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.

Download Snippet

Custom Field Confirmation

This field is for validation purposes and should be left unchanged.