You are here

function text_captcha_settings_form_validate in CAPTCHA 6

Same name and namespace in other branches
  1. 5.3 text_captcha/text_captcha.module \text_captcha_settings_form_validate()

Validate function of the administration form

1 string reference to 'text_captcha_settings_form_validate'
text_captcha_settings_form in text_captcha/text_captcha.admin.inc
Administration form

File

text_captcha/text_captcha.admin.inc, line 42

Code

function text_captcha_settings_form_validate($form, &$form_state) {
  if ($form_state['values']['text_captcha_words'] == TEXT_CAPTCHA_USER_DEFINED_WORDS) {

    // check if there are at minimum TEXT_CAPTCHA_USER_DEFINED_WORD_MINIMUM user defined words
    if (count(explode(' ', $form_state['values']['text_captcha_userdefined_words'])) < TEXT_CAPTCHA_USER_DEFINED_WORD_MINIMUM) {
      form_set_error('text_captcha_userdefined_words', t('You need to enter at least @min words if you want to use user defined words.', array(
        '@min' => TEXT_CAPTCHA_USER_DEFINED_WORD_MINIMUM,
      )));
    }
  }

  // chech text_captcha_word_quantity
  $word_quantity = (int) $form_state['values']['text_captcha_word_quantity'];
  if ($word_quantity < 4 || $word_quantity > 10) {
    form_set_error('text_captcha_word_quantity', t('Number of words in the phrase should be between 4 and 10.'));
  }
}