Ensure Two of the Same Value
Last updated on
30 April 2025
You are browsing documentation for an older version of Drupal, which is not supported any longer, and the information may not be correct. See current documentation for Contributed modules
This can be a useful bit of code to ensure that two fields are filled in with the same value (such as two email address that must match).
Create two e-mail components with the field keys 'email1' and 'email2'. Then in the "Webform advanced settings" fieldset, enter this code into the Additional validation text field.
if ($form_values['submitted_tree']['email1'] != $form_values['submitted_tree']['email2']) {
form_set_error('submitted][email1', t('E-mail addresses must match.'));
}
Help improve this page
Page status: Not set
You can:
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion