function mp3player_player_validate in MP3 Player 6
Custom validation function for the system settings form.
2 string references to 'mp3player_player_validate'
- mp3player_player_add in ./
mp3player.module - Form to add a new player.
- mp3player_player_edit in ./
mp3player.module - Form to edit a player.
File
- ./
mp3player.module, line 754 - mp3player main module file.
Code
function mp3player_player_validate($form, &$form_state) {
$players = mp3player_players();
if (isset($form_state['values']['pid'])) {
unset($players[$form_state['values']['pid']]);
}
foreach ($players as $pid => $player) {
if ($player['name'] == $form_state['values']['name']) {
form_set_error('name', t('Player name has to be unique.'));
}
}
if (preg_match('/[^0-9a-zA-Z_-]/', $form_state['values']['name'])) {
form_set_error('name', t('Please only use alphanumeric characters, underscores (_), and hyphens (-) for player names.'));
}
if ($form_state['values']['name'] != '' && strlen($form_state['values']['name']) >= 20) {
form_set_error('name', t('Player name must be 20 characters long or shorter.'));
}
if ($form_state['values']['initialvolume'] < 0 || $form_state['values']['initialvolume'] > 100) {
form_set_error('initialvolume', t('Volume must be between 0 and 100.'));
}
if (!is_numeric($form_state['values']['buffer'])) {
form_set_error('buffer', t('Buffer must be an integer.'));
}
$percentage = strstr($form_state['values']['width'], '%');
if (!is_numeric($form_state['values']['width']) && $percentage != '%') {
form_set_error('width', t('Width must be an integer or percentage.'));
}
if ($form_state['values']['pagebg'] != '' && strlen($form_state['values']['pagebg']) != 6) {
form_set_error('pagebg', t('HEX code must be 6 characters long.'));
}
if (strlen($form_state['values']['bg']) != 6) {
form_set_error('bg', t('HEX code must be 6 characters long.'));
}
if (strlen($form_state['values']['leftbg']) != 6) {
form_set_error('leftbg', t('HEX code must be 6 characters long.'));
}
if (strlen($form_state['values']['lefticon']) != 6) {
form_set_error('lefticon', t('HEX code must be 6 characters long.'));
}
if (strlen($form_state['values']['voltrack']) != 6) {
form_set_error('voltrack', t('HEX code must be 6 characters long.'));
}
if (strlen($form_state['values']['volslider']) != 6) {
form_set_error('volslider', t('HEX code must be 6 characters long.'));
}
if (strlen($form_state['values']['rightbg']) != 6) {
form_set_error('rightbg', t('HEX code must be 6 characters long.'));
}
if (strlen($form_state['values']['rightbghover']) != 6) {
form_set_error('rightbghover', t('HEX code must be 6 characters long.'));
}
if (strlen($form_state['values']['righticon']) != 6) {
form_set_error('righticon', t('HEX code must be 6 characters long.'));
}
if (strlen($form_state['values']['righticonhover']) != 6) {
form_set_error('righticonhover', t('HEX code must be 6 characters long.'));
}
if (strlen($form_state['values']['loader']) != 6) {
form_set_error('loader', t('HEX code must be 6 characters long.'));
}
if (strlen($form_state['values']['track']) != 6) {
form_set_error('track', t('HEX code must be 6 characters long.'));
}
if (strlen($form_state['values']['tracker']) != 6) {
form_set_error('tracker', t('HEX code must be 6 characters long.'));
}
if (strlen($form_state['values']['border']) != 6) {
form_set_error('border', t('HEX code must be 6 characters long.'));
}
if (strlen($form_state['values']['skip']) != 6) {
form_set_error('skip', t('HEX code must be 6 characters long.'));
}
if (strlen($form_state['values']['text']) != 6) {
form_set_error('text', t('HEX code must be 6 characters long.'));
}
}