I have enabled the Clientside Validation FAPI module but it does not seem to be firing.

I have not changed any of the default settings. Based on the documentation, I am under the impression that the module should interpret my currently implemented validation rules and convert them to client-side rules but this does not seem to be occurring. The form validates correctly on submit.

I am happy to provide more information but I am not sure what is pertinent based on the fact that the documentation says it should just work.

Comments

markdorison’s picture

The validation seems to be working as expected for fields on node edit forms.

attiks’s picture

So this is fixed?

attiks’s picture

Status: Active » Closed (works as designed)

if not re-open

markdorison’s picture

Status: Closed (works as designed) » Active

This is not fixed. It works correctly for node edit forms, but not on a custom FAPI form that I created.

attiks’s picture

Can you post the form code?

markdorison’s picture

@attiks: Absolutely.

function restaurant_private_dining_form($form, &$form_state) {
  $current_restaurant_node = ''; // Hidden
  $recipient_email = ''; // Hidden

  $form['#attributes']['class'][] = 'private-dining-form';
  $form['description'] = array(
    '#type' => 'item',
    '#title' => t('Private Dining Request Form:'),
    '#description' => t('Description'),
  );

  $form['restaurant_name'] = array(
    '#type' => 'hidden',
    '#value' => $current_restaurant_node->title,
  );
  $form['recipient'] = array(
    '#type' => 'hidden',
    '#value' => $recipient_email,
  );
  $form['name'] = array(
    '#type' => 'fieldset',
    '#title' => t('Name'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['name']['first'] = array(
    '#type' => 'textfield',
    '#title' => t('First name:'),
    '#required' => TRUE,
  );
  $form['name']['last'] = array(
    '#type' => 'textfield',
    '#title' => t('Last name:'),
    '#required' => TRUE,
  );

  $form['phone_number'] = array(
    '#type' => 'telfield',
    '#title' => t('Phone number:'),
    '#required' => TRUE,
  );
  $form['email'] = array(
    '#type' => 'emailfield',
    '#title' => t('Your Email:'),
    '#required' => TRUE,
    '#rules' => array(
      'email',
    ),
  );
  $form['company'] = array(
    '#type' => 'textfield',
    '#title' => t('Company/Organization:'),
  );
  $form['date'] = array(
    '#type' => 'date',
    '#title' => t('Event date:'),
  );
  $form['time'] = array(
    '#type' => 'select',
    '#title' => t('Event time:'),
    '#options' => array(
      1200 => '12:00pm',
      1230 => '12:30pm',
      1300 => '1:00pm',
      1330 => '1:30pm',
      1400 => '2:00pm',
      1430 => '2:30pm',
      1500 => '3:00pm',
      1530 => '3:30pm',
      1600 => '4:00pm',
      1630 => '4:30pm',
      1700 => '5:00pm',
      1730 => '5:30pm',
      1800 => '6:00pm',
      1830 => '6:30pm',
      1900 => '7:00pm',
      1930 => '7:30pm',
      2000 => '8:00pm',
      2030 => '8:30pm',
      2100 => '9:00pm',
      2130 => '9:30pm',
      2200 => '10:00pm',
      2230 => '10:30pm',
      2300 => '11:00pm',
      2330 => '11:30pm',
    ),
    '#default_value' => 1700,
  );
  $form['guest_count'] = array(
    '#type' => 'select',
    '#title' => t('Number of Guests:'),
    '#options' => array(
      10 => '10',
      11 => '11',
      12 => '12',
      13 => '13',
      14 => '14',
      15 => '15',
      16 => '16',
      17 => '17',
      18 => '18',
      19 => '19',
      20 => '20',
      25 => '25+',
      30 => '30+',
      35 => '35+',
      40 => '40+',
      45 => '45+',
      50 => '50+',
      60 => '60+',
      70 => '70+',
      80 => '80+',
      90 => '90+',
      100 => '100+',
    ),
  );
  $form['special_event_subscribe'] = array(
    '#type' => 'checkbox',
    '#title' => t('I would like to receive special event info from this restaurant.'),
  );
  $form['comments'] = array(
    '#title' => t('Comments'),
    '#type' => 'textarea',
  );
  $form['how_did_you_hear'] = array(
    '#type' => 'select',
    '#title' => t('How did you hear about us?'),
    '#options' => array(
      'Frequent Customer',
      'Tour Operator',
      'Concierge',
      'CVB',
      'Advertisement',
      'Magazine',
      'Newspaper Article',
      'Meeting Planner',
      'Referred by a friend',
      'Other',
    ),
  );
  // This field should be hidden with CSS. It is placed here so that spam bots
  // will fill it.
  $form['validuser'] = array(
    '#type' => 'textfield',
    '#title' => t('What is the current web site\'s url?'),
    '#required' => FALSE,
  );

  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Submit',
  );
  return $form;
}
attiks’s picture

I tried your form, but what isn't working for you?

If you use emailfield as type, there's no need to add a rule for email, the following works as well:

  $form['email'] = array(
    '#type' => 'emailfield',
    '#title' => t('Your Email:'),
    '#required' => TRUE,
  );

The latest dev version now also supports custom rules on email, phone and link field

markdorison’s picture

The validation gets fired on POST instead of on the client end. When I compare this to a node form, I can see that on the node form the client-side validation occurs on submit with no POST, whereas the form I posted in comment #6 posts back in typical Drupal core fashion before it presents the validation results.

attiks’s picture

Assigned: Unassigned » jelle_s

Do you get any javascript errors? Did you change the settings?

jelle_s’s picture

Status: Active » Fixed

Clientside validation was not fired because we didn't have support for 'required' on the phone and e-mail fields.

fixed in the latest dev version

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.