You are here

function ahah_example_simple_validation_validate in Examples for Developers 6

Validation function for the form. Requires that two words be entered.

File

ahah_example/ahah_example_simple_validation.inc, line 40
Demonstrate validation of a textfield using AHAH. This approach allows 'live' validation of a field which degrades gracefully when JavaScript is not available.

Code

function ahah_example_simple_validation_validate(&$form, &$form_state) {
  $words = explode(' ', $form_state['values']['two_words_required']);
  if (count($words) < 2) {
    form_set_error('two_words_required', t('You have to enter at least two words'));
  }
}