When your form is submitted, it will pass through a validation function if you define one. The function name should be nameofyourform_validate($form, &$form_state)
See http://drupal.org/node/751826 (The Drupal forms quickstart guide).
This function will be automatically called when a user submits your form. Inside this function, you can check on the values of $form and use PHP's is_numeric to be sure that $form_state['ci'] is a numerical value. If it is not (that is, if is_numeric returns FALSE), use form_set_error to invalidate the submission and return the user to the form page with an error message.
Hello:
I need your help. I'm making a Drupal module, and i need to validate if the textfield data are numeric or not. can i use a drupal functions for this ?
This is my form code:
'ci' => array (
'#title' => t('C.I.'),
'#type' => 'textfield',
'#maxlength' => 11,
'#size' => 20,
'#required' => TRUE,
),
Thanks.