function math_captcha_settings_form_validate in CAPTCHA Pack 7
Same name and namespace in other branches
- 5 math_captcha/math_captcha.module \math_captcha_settings_form_validate()
- 6 math_captcha/math_captcha.admin.inc \math_captcha_settings_form_validate()
Validation function for Math CAPTCHA settings form
1 string reference to 'math_captcha_settings_form_validate'
- math_captcha_settings_form in math_captcha/
math_captcha.admin.inc - Math CAPTCHA settings form
File
- math_captcha/
math_captcha.admin.inc, line 97 - Functionality and helper functions for MATH CAPTCHA administration.
Code
function math_captcha_settings_form_validate($form, &$form_state) {
// Check enabled challenges
if (count(array_filter($form_state['values']['math_captcha_enabled_challenges'])) < 1) {
form_set_error('math_captcha_enabled_challenges', t('You should select at least one type of math challenges.'));
}
// Check argmax's
$argmaxs = array(
'math_captcha_addition_argmax',
'math_captcha_subtraction_argmax',
'math_captcha_multiplication_argmax',
);
foreach ($argmaxs as $argmax) {
if (!ctype_digit($form_state['values'][$argmax])) {
form_set_error($argmax, t('Maximum value should be an integer.'));
}
else {
$form_state['values'][$argmax] = intval($form_state['values'][$argmax]);
if ($form_state['values'][$argmax] < 2) {
form_set_error($argmax, t('Maximum value should be an integer and at least 2'));
}
}
}
}