function regcode_roles_admin_validate in Registration codes 7
Same name and namespace in other branches
- 6.2 regcode_roles/regcode_roles.module \regcode_roles_admin_validate()
- 6 regcode_roles/regcode_roles.module \regcode_roles_admin_validate()
- 7.2 regcode_roles/regcode_roles.module \regcode_roles_admin_validate()
Validate date input.
File
- regcode_roles/
regcode_roles.module, line 162 - Main functionality of regcode_role module.
Code
function regcode_roles_admin_validate($form, $form_state) {
// Role expire stuff.
if (module_exists('role_expire')) {
if (!empty($form_state['values']['expiry_duration'])) {
if ((int) $form_state['values']['expiry_duration'] < 1) {
form_set_error('expiry_duration', t('Invalid duration provided, duration must be greater than or equal to 1 day.'));
}
}
if (!empty($form_state['values']['expiry_date'])) {
if (!($expire_date = strtotime($form_state['values']['expiry_date']))) {
form_set_error('expiry_date', t('Invalid date provided, please provide a date in a format strtotime can handle.'));
}
elseif ($expire_date < REQUEST_TIME) {
form_set_error('expiry_date', t('Expiry date must be in the future.'));
}
}
}
}