Validating Fax Number
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
$fax = $form_values['submitted_tree']['fax'];
if (strlen(trim($fax)) > 0) {
if (!ereg("^[0-9]{1,3}-[0-9]{3}-[0-9]{3,4}-[0-9]{3,4}$";, $fax)) {
form_set_error('submitted][fax', t('Fax number must be in format xxx-xxx-nnnn-nnnn.'));
}
}
The if (strlen(trim($fax)) > 0) { line ensures the number is optional for the end-user.
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