I have created a group of checkboxes in my form. When they are being validated, it displays error messages for each checkbox. But what I need is, to display only one error message for that group of checkboxes. Can you please tell me how can I do this?

#3 Selection_045.png30.03 KBJelle_S
Members fund testing for the Drupal project. Drupal Association Learn more


Jelle_S’s picture

How have you created the group of checkboxes?

  • Form API
  • CCK
  • ...

Can you provide me steps to reproduce?

nishyaadi’s picture

Sure :-)

I installed cck and using that I created a field named "Available sectors" in my form. Then I set the type as 'text' and widget as 'checkboxes/radio buttons'. After that I included 5 values in the 'Allowed values' field and set as required. When I'm trying to validate that field using clientside validation it displays the error message "Available sectors field is required." for 5 times. But what I need is to display only one error message for that field("Available sectors") which I created.

Jelle_S’s picture

30.03 KB

I tried reproducing the bug, but didn't get it. What version of clientside validation are you using? Have you tried the latest dev version?

Here's how it looks at my end:


nishyaadi’s picture

Yes, I have tried it. I'm using clientside_validation-6.x-1.x-dev version. But it gives 5 error messages in my end.

Jelle_S’s picture

That's weird,

what version of cck are you using?

Davidovich’s picture

I have come across a similar issue using the 7.x versions and traced the issue back to using spaces in input names.

Basically, this validates correctly:

    'optionswithoutspaces' => array(
      '#type' => 'checkboxes',
      '#title' => t('Options without spaces'),
      '#options' => drupal_map_assoc(
      '#required' => TRUE,

This produces 5 error messages:

  'optionswithspaces' => array(
      '#type' => 'checkboxes',
      '#title' => t('Options with spaces'),
      '#options' => drupal_map_assoc(        array(
          'Option 1',          
          'Option 2',
          'Option 3',
          'Option 4',
          'Option 5',
      '#required' => TRUE,

This is down to the fact that jQuery validate splits the list of grouped fields on spaces, causing them to get all screwed up.

Not sure if this is the same issue you were having, but it seems the same.

Jelle_S’s picture

@Davidovich: You are correct. I see you already created a pull request in their issue queue. Thanks for that! Until that is committed, I can only advise you to use machine readable option keys.

Jelle_S’s picture

Status: Active » Postponed

Waiting for the pull request...

attiks’s picture

Jelle_S’s picture

This is fixed in 7.x, I'm getting js errors in 6.x with practically the same code so I'm not sure why...

Jelle_S’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Postponed » Fixed

found it. fixed in both dev versions.

Status: Fixed » Closed (fixed)

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