You are here

function webform_email_address_validate in Webform 6.3

Same name and namespace in other branches
  1. 7.4 includes/webform.emails.inc \webform_email_address_validate()
  2. 7.3 includes/webform.emails.inc \webform_email_address_validate()

Validate handler for webform_email_edit_form() and webform_emails_form().

2 string references to 'webform_email_address_validate'
webform_emails_form in includes/webform.emails.inc
Overview form of all components for this webform.
webform_email_edit_form in includes/webform.emails.inc
Form for configuring an e-mail setting and template.

File

includes/webform.emails.inc, line 370
Provides interface and database handling for e-mail settings of a webform.

Code

function webform_email_address_validate($form, &$form_state) {
  if ($form_state['values']['email_option'] == 'custom') {
    $email = trim($form_state['values']['email_custom']);
    if (empty($email)) {
      form_set_error('email_custom', t('When adding a new custom e-mail, the e-mail field is required.'));
    }
    else {
      $emails = array_filter(explode(',', $email));
      foreach ($emails as $email) {
        if (!valid_email_address(trim($email))) {
          form_set_error('email_custom', t('The entered e-mail address "@email" does not appear valid.', array(
            '@email' => $email,
          )));
        }
      }
    }
  }
}