Cognito Forms – How to Validate Two Fields Have Same Value

cognito-forms

I would like to verify that the email confirmation field has the same value as the email field on my form. I want to show an error massage when it does not match. How can I do that on the form?

Best Answer

In Cognito Forms, you can use the Show Custom Error option to show error messages for any reason.

In this case, you can show an error message when your two email address fields do not have the same value. Here are the steps to do this:

  1. Add an Email field called "Email"
  2. Add a second Email field called "Confirmation Email"
  3. For this confirmation field, select Show Custom Error - When
  4. Switch to the Advanced Editor and enter this calculation: =(ConfirmationEmail != Email)
  5. Click Save to close the conditional logic dialog
  6. Enter the error message you wish to show when this error occurs

Here is what this will look like when you are entering the validation calculation:

enter image description here