Drupal Answers is a question and answer site for Drupal developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
    
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 2 hours ago

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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