Clientside-validation for form-api for field either digits or empty A particular form field can be left blank or filled with digits, with no other valid characters including dash"-"

$form['hours'] = array(
    '#type' =&gt; 'textfield',
    '#title' =&gt; t('Hours worked per week'),
    '#size' =&gt; 3, 
    '#maxlength' =&gt; 3, 
    '#default_value' =&gt; '',
    '#rules' =&gt; array(
      "digit",
      'length[0, 3]',
    ),
    '#filters' =&gt; array('numeric', 'trim')
  );


I have a minimum length of 0, but an empty field appears to be invalid.  I've tried using "numeric" instead of "digit" but this allows dashes.

Is there some way to do this without using a custom handler?
The way I did this was to add a custom validation handler.  I know I asked for a solution without one, but it turned out to be a fairly simple thing to do.  See the "#element_validate' array element below.  

$form['hours'] = array(
  '#type' =&gt; 'textfield',
  '#title' =&gt; t('Hours worked per week'),
  '#size' =&gt; 3, 
  '#maxlength' =&gt; 3,
  '#element_validate' =&gt; array('mymodule_validate_integer'),
  '#default_value' =&gt; '',
  '#rules' =&gt; array(),
  '#filters' =&gt; array('numeric', 'trim')
);

function mymodule_validate_integer($element, &amp;$form_state, $form) {
  if (!empty($element['#value']) &amp;&amp; (!is_numeric(parse_size($element['#value'])) || $element['#value'] &lt; 0)) {
    form_error($element, t('"!name" must be a positive number.', array('!name' =&gt; t($element['#title']))));
   }
 }


function mymodule_clientside_validation_rule_alter(&amp;$js_rules, $element, $context) {
switch($context['type']) {
case 'element_validate':
  if (in_array('mymodule_validate_integer', $context['functions'])) {
    _clientside_validation_set_minmax(
        $element['#name'], 
        $element['#title'], 
        0, 
        99999, 
        $js_rules, 
        t('"!name" must be a positive number.', array('!name' =&gt; t($element['#title'])))
    );
  }
  break;
  } 
}


I hope this helps someone in the future.