I am trying to apply clientside validation on a form which is being displayed in quicktabs But on submitting the form am getting the whole ajax callback and nothing else.

The form contains a title field and submit.
The validations work on this form everywhere else, but not when i use it in a quicktab. Even when i enter validated data, the form does not submit but redirects and displays the ajax callback.

Code for form is as below.

function cdin_story_pre_create_form($form, &$form_state) {
  $lang = 'und';
  
  $form['heading'] = array(
    '#type' => 'markup',
    '#markup' => '<h3>Create a new Story</h3>',
  );

  // Attaching project_type field.
  $node = new stdClass();
  $node->type = "story";


  field_attach_form('node', $node, $form, $form_state, NULL, array('field_name' => 'title_field'));


  $form['title_field'][$lang][0]['value']['#required'] = TRUE;
  $form['title_field'][$lang][0]['value']['#rules'] = array(
      array('rule' => 'regexp[/^[a-zA-Z0-9 ]*$/]', 'error' => t('Invalid Title Format.')),
    );

  // Form submit button.
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
    '#weight' => 100,
  );

  
  return $form;
}

Comments

aaghran’s picture

I was able to get a workaround on this. Submitting a patch. I don't know wether it's the right way or not but it is working now.

Leeteq’s picture

Hi @aaghran, did you try to attach a patch? (if a problem, just paste the code in code tags)

Jelle_S’s picture

Status: Active » Postponed (maintainer needs more info)

By default, Clientside Validation does not validate hidden fields. This is a setting that can be changed. Could you check if that's the problem? If not I'll do some testing myself.