Hey guys and gals,

I ran into a little bit of updating issue.

Seen Below is a little snippet of the code in drupal 5.x:

function synth_product_validate($form, &$form_state) {

if (!is_numeric($node->product_quantity)) {
form_set_error('product_quantity', t('Quantity (in mg) must be a number.'));
}
return;
}

when executing a form submit, i get an error saying product_quantity is not a number even though it is. I know that ! reverses the is_numeric function and that validate function has additional parameter...but i don't know where to begin.

Many thanks in advance

Comments

sunil.cms’s picture

You are using $node object which you don't get in form validate function. Try with the code below

function synth_product_validate($form, &$form_state) {
  if (!is_numeric($form_state['values']['product_quantity'])) {
    form_set_error('product_quantity', t('Quantity (in mg) must be a number.'));
  }
return;
}