A particular form field can be left blank or filled with digits, with no other valid characters including dash"-"
$form['hours'] = array(
'#type' => 'textfield',
'#title' => t('Hours worked per week'),
'#size' => 3,
'#maxlength' => 3,
'#default_value' => '',
'#rules' => array(
"digit",
'length[0, 3]',
),
'#filters' => 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?