Way to have a theme-settings form input to accept numbers only? I am creating some theme settings and am creating a form to populate them in theme-settings.php. I am using the hook hook_form_system_theme_settings_alter().

I would like to restrict or verify that only numbers can be entered into a field. I've searched online but have not found how to do this. Would anyone know what I ought to add to my code?

Code currently looks like:

$form['mysite_theme']['mysite_contact_phone'] = array(
    '#type' =&gt; 'textfield',
    '#title' =&gt; t('Contact Number'),
    '#default_value' =&gt; $default['mysite_contact_phone'],
    '#description' =&gt; t('Enter the main contact number for this site.'),
    '#required' =&gt; TRUE,
  );
You should be able to add your own validation handler. After the code you've shown, add this:

$form['#validate'][] = 'my_validation_handler';


Then in your handler, you can add your own validation:

function my_validation_handler($form, &amp;$form_state)
{
  if(!is_numeric($form_state['values']['mysite_contact_phone']))
  {
    form_set_error('mysite_contact_phone', t('Contact number must be numeric'));
  }
}