I would appreciate seeing a simple example of using this module to require a user to enter a number in a field. That's all I want to do. Nothing fancy. Something like this:

$form['amount'] = array(
  '#type' => 'textfield',
  '#required' => true,
  '#title' => t('Amount'),
);

Assuming that I have enabled the Clientside Validation and Clientside Validation Form modules, what do I have to add to this element array to get the number validation?

Thanks.

Comments

attiks’s picture

You can try the following, or use the elements module to enable html5 number field

Integer

  $form['amount'] = array(
    '#type' => 'textfield',
    '#required' => true,
    '#title' => t('Amount'),
    '#number_type' => 'integer',
  );  

Decimal

  $form['amount'] = array(
    '#type' => 'textfield',
    '#required' => true,
    '#title' => t('Amount'),
    '#number_type' => 'decimal',
  );  
attiks’s picture

Category: support » task
Issue tags: +Needs documentation