I can't figure what to add Client Side Validation for form fields.

'#element_validate' => array('_file_generic_settings_max_filesize'),

I also don't know which value to put for different types of validation such as digit, email etc. '#element_validate' => 'email',

Also if I use this documentation https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7.x/#element_validate:

'#element_validate' => array('email'),

it states that it needs to be string not an array.

And after all this documentation doesn't state that how to add validation instead just creating own validation: https://www.drupal.org/node/1324788

  • The Drupal FAPI doesn't provide clientside validation by default. You either need to add your own, or you need to find contributed modules that handle it for you.
    – Jaypan
    Nov 22, 2016 at 14:06

1 Answer 1


Solution was to add following for each integer field with form alter:

['#rules'] = array('digit');

And perhaps it was also needed to set 'views_exposed_filters' as a custom form for validation in the settings of Client Side Validation module.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.