function honeypot_admin_form_validate in Honeypot 6
Same name and namespace in other branches
- 7 honeypot.admin.inc \honeypot_admin_form_validate()
Validate the admin form.
File
- ./
honeypot.admin.inc, line 142 - Honeypot administration form.
Code
function honeypot_admin_form_validate($form, &$form_state) {
// Make sure the time limit is a positive integer or 0.
$time_limit = $form_state['values']['honeypot_time_limit'];
if (is_numeric($time_limit) && $time_limit > 0 || $time_limit === '0') {
if (ctype_digit($time_limit)) {
// Good to go.
}
else {
form_set_error('honeypot_time_limit', t("The time limit must be a positive integer or 0."));
}
}
else {
form_set_error('honeypot_time_limit', t("The time limit must be a positive integer or 0."));
}
// Make sure Honeypot element name only contains A-Z, 0-9.
if (!preg_match("/^[-_a-zA-Z0-9]+\$/", $form_state['values']['honeypot_element_name'])) {
form_set_error('honeypot_element_name', t("The element name cannot contain spaces or other special characters."));
}
}