Require one of two fields be filled out
Last updated on
30 April 2025
This code makes it so that a user must fill out one of two possible fields.
// Grab variables.
$email = $form_values['submitted_tree']['email_address'];
$phone = $form_values['submitted_tree']['phone_number'];
// Check for values.
if ($email == "" && $phone == "") {
form_set_error('submitted][email_address', t('E-mail Addresses or Phone Number must be given.'));
form_set_error('submitted][phone_number', '');
}
Requires that an email or phone number is given.
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