[development] Form Textfield numeric
william.darren at gmail.com
Thu Mar 10 16:59:35 UTC 2011
When your form is submitted, it will pass through a validation function if
you define one. The function name should be nameofyourform_validate($form,
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.
On Thu, Mar 10, 2011 at 11:46 AM, Damian Adriel Perez Valdes <
damian.adriel at gmail.com> wrote:
> 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,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the development