You are here

function faq_ask_form_validate in FAQ_Ask 7

Same name and namespace in other branches
  1. 8 faq_ask.module \faq_ask_form_validate()
  2. 6.2 faq_ask.module \faq_ask_form_validate()

Validation form for the FAQ Ask form

Verifies that the e-mail entered seems to be a valid e-mail. Thanks to http://hokuten.net/2010/drupal-creating-an-e-mail-subscription-block/

Parameters

array $form: The edit form to validate.

array $form_state: Form state information

Return value

void

1 string reference to 'faq_ask_form_validate'
faq_ask_form_faq_node_form_alter in ./faq_ask.module
Implements hook_form_FORM_ID_alter().

File

./faq_ask.module, line 368
This module is an add-on to the FAQ module that allows users with the 'ask question' permission to create a question which will be queued for an 'expert' to answer.

Code

function faq_ask_form_validate($form, &$form_state) {
  if (isset($form_state['values']['faq_email']) && 2 < strlen($form_state['values']['faq_email'])) {
    $email = $form_state['values']['faq_email'];
    if (!valid_email_address($email)) {
      form_set_error('email', t('That is not a valid e-mail address.'));
    }
  }
  else {

    // Issue #1569684 by jlea9378: Not a valid e-mail address
    unset($form_state['values']['faq_email']);
  }
}