Hello everybody

I have made a form and set hook-validation on it
I found out there is a function for validate an email( valid_email_address) and also for empty fields(empty)

Now i was wondering... is there something like this for only numbers? and for only letters?

Thanx in advance

Comments

shady_gun’s picture

instead use php functions

for validating integers

$value = $form_state['values']['cost'];
  if ($value && !is_numeric($value)) {
    form_set_error('min', t('"Cost" must be a number.'));
  }

for only taking string use any regular expressions there are many available on net

jeebsuk’s picture

There is the function "valid_email_address". It's not perfect by a long way, but it does the basics.