function shoutbox_add_form_validate in Shoutbox 6.2
Same name and namespace in other branches
- 5 shoutbox.module \shoutbox_add_form_validate()
- 6 shoutbox.module \shoutbox_add_form_validate()
- 7.2 shoutbox.module \shoutbox_add_form_validate()
- 7 shoutbox.module \shoutbox_add_form_validate()
Makes sure uses don't submit default values.
Parameters
$form_id: The form ID of the form.
$form_values: Form values.
File
- ./
shoutbox.module, line 483 - Shout box module displays a block for users to create short messages for the whole site. Uses AHAH to update the database and display content.
Code
function shoutbox_add_form_validate($form, &$form_state) {
// Remove trailing whitespace
$form_state['values']['message'] = trim($form_state['values']['message']);
$max = variable_get('shoutbox_max_length', 255);
// Empty message
if (!$form_state['values']['message']) {
form_set_error('message', t('You must enter a message.'));
}
else {
if ($max && strlen($form_state['values']['message']) > $max) {
form_set_error('message', t('Your shout is too long. Only @max characters are allowed.', array(
'@max' => $max,
)));
}
}
}