You are here

function simplenews_subscriptions_page_form_validate in Simplenews 7.2

Same name and namespace in other branches
  1. 6.2 includes/simplenews.subscription.inc \simplenews_subscriptions_page_form_validate()
  2. 7 includes/simplenews.subscription.inc \simplenews_subscriptions_page_form_validate()

FAPI PAGE subscription form_validate.

2 string references to 'simplenews_subscriptions_page_form_validate'
simplenews_subscriptions_multi_block_form in includes/simplenews.subscription.inc
FAPI MULTI BLOCK subscription form.
simplenews_subscriptions_page_form in includes/simplenews.subscription.inc
FAPI PAGE subscription form.

File

includes/simplenews.subscription.inc, line 304
(Un)subscription and (un)subscription confirmation

Code

function simplenews_subscriptions_page_form_validate($form, &$form_state) {
  $valid_email = valid_email_address($form_state['values']['mail']);
  if (!$valid_email) {
    form_set_error('mail', t('The e-mail address you supplied is not valid.'));
  }
  $checked_newsletters = array_filter($form_state['values']['newsletters']);

  // Unless we're in update mode, at least one checkbox must be checked.
  if (!count($checked_newsletters) && $form_state['values']['op'] != t('Update')) {
    form_set_error('newsletters', t('You must select at least one newsletter.'));
  }
}