For example you want the user to check that he agrees to terms of use, etc..

Comments

Jelle_S’s picture

Status: Active » Postponed (maintainer needs more info)

Can you be more specific? I just tested with the latest dev version and a single on/off checkbox that is required works for forms built with the Form API, for fields on entities and for webforms...

What exactly isn't working for you?

Jelle_S’s picture

Spammer... has been reported

ramsegal’s picture

Spammer? huh?

I had to add a require rule with hook_validation_fapi_validation_rules, if i use only '#required'=>TRUE to the field, it's only been validated server side..

Thanks anyways.

Jelle_S’s picture

Sorry, that wasn't about you, if you look closely, comment #2 is deleted, because the spammer account was deleted ;-)

If you get the latest dev version from git, it should work only setting '#required' => TRUE

attiks’s picture

On what form did you have this: custom form, user registration form, ... Any other modules you used?

ramsegal’s picture

Hi, thanks for supporting!

It happens to me on a custom form, the field code:

$form['legal'] = array(
  '#type' => 'checkbox',
  '#title' => t('Terms and Conditions'),
  '#title_display' => 'invisible',
  '#field_suffix' => t('I have read, understood and accepted all the <a href="@legal" target="_blank">Terms and Conditions</a> and the client disclosure', array('@legal' => url('about-us/legal'))),
  '#default_value' => 0,
  '#required' => TRUE,
);

For this code, i can submit the form, no clientside validation.

I added a custom rule with hook_validation_fapi_validation_rules, and used fapi (#rules => ...), so on submit the checkbox is validated, however no message to the user...

I am still struggling with this, i don't want to update to the latest dev version because i want to keep the inline error messages (and one error message at a time)

Thanks!

attiks’s picture

I tried this using the following and it works (latest dev version), any javascript errors? What does Drupal.settings.clientsideValidation look like when you view the source of the page?

function clientside_validation_example_1565422($form_state) {
  $form = array();

  $form['legal'] = array(
    '#type' => 'checkbox',
    '#title' => t('Terms and Conditions'),
    '#title_display' => 'invisible',
    '#field_suffix' => t('I have read, understood and accepted all the <a href="@legal" target="_blank">Terms and Conditions</a> and the client disclosure', array('@legal' => url('about-us/legal'))),
    '#default_value' => 0,
    '#required' => TRUE,
  );  
  
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Send'),
    '#weight' => 100
  );

  return $form;
}

attiks’s picture

Status: Postponed (maintainer needs more info) » Active
ak’s picture

Hi, I am using this on a simple node form. I got the same problem with the 7.x-1.31 release. It's only validating textfields and texareas but no error messages for checkbox or select dropdowns.

I tried using the current dev version as mentioned but that gives me a php error with my hierarchical select taxonomy field:
(Notice: Undefined index: field_country[und] in clientside_validation_regular() (line 172 of … /clientside_validation_form.module))

A lot has hanged in the current dev version. Is there a simple fix or patch to this issue for the 7.x-1.31 release?
Thank's for advice.

attiks’s picture

What version of Drupal are you using?

ak’s picture

My site is running Drupal 7.12. Is the Drupal version related?

attiks’s picture

Do you get any javascript errors?
Can you post the content of Drupal.settings.clientside_validation?
Is this is a single checkbox or multiple?
Post a screenshot if you can

ramsegal’s picture

I installed the latest dev version (22-05-12), no luck, required checkbox isnt being validated.

attiks’s picture

@ramsegal, what's the difference between your form and the one in #8

ramsegal’s picture

i have some more fields, one special - captcha.

other than that...same.

Jelle_S’s picture

I just tested with this (very basic) form and the checkbox got validated:

  $form['checkbox'] = array(
    '#type' => 'checkbox',
    '#title' => t('Required checkbox'),
    '#required' => TRUE,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Submit',
  );

@ramsegal:
What do your js settings look like? Could you post it here?

ak’s picture

I am now going with the dev version of this module.
I can confirm that is does validate my checkbox and my node reference select box as expected.

In response to #13 and version 7.x-1.31:
– No Javascript errors occur.
– It's a single checkbox, a taxonomy term- and node reference-select box.
– Btw. I got jquery_update module installed with jquery 1.5.x.
– Here's some settings code, the checkbox as example appears:

"clientsideValidation" : { "forms" : { "answer-node-form" : { 
  "checkboxrules" : { "field_agree[und]" :
    { "checkboxgroupminmax" : [ 1, 99, "#edit-field-agree-und"],
      "messages" : { "checkboxgroupminmax" : "\"Terms\" is required." }
} },
…
attiks’s picture

jquery_update might be the problem, but not sure

Jelle_S’s picture

just tested the form from #17 again with jquery update enabled (jquery-1.5.2) and everything still worked as it should...

Jelle_S’s picture

@ak: can you post a screenshot of your fields (so I can see the type & widget) so I can try to reproduce?

ak’s picture

The dev version fixed the problem for me. Checkboxes and selects validate fine with dev, so I'm sticking with that. I would recommend to make a new full releas version asap that fixes this bug for all users. Best regards.

attiks’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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

ramsegal’s picture

I found the problems i had:

1. select - i use the module selectmenu, which breaks the clientside validation.
2. checkbox - i have a multistep form, which i didnt implement right. the checkbox is in the second step. because i called the form builder function directly, the validation was on the first step elements, once i changed it to drupal_get_form everything works as expected.

So nothing related to clientside validation module..

Thanks for the support

pyxio’s picture

Issue summary: View changes

I have the same problem with a single on/off boolean checkbox on user register form. If i check the field settings i see the Exclude from clientside validation option and it is unchecked. If I check source code there is no validation error label being created for this specific form element. I am using module version 7.x-1.44

asamant6’s picture

Recently I have faced one issue due to use of clientside_validation module (v1.46).
Issue :: If user submits a form without filling any data, error list will be shown as expected. After this if user selects first mandatory checkbox (first input also) , all errors will hide from the error list at a glance. Again if user unchecks the checkbox, only one error related to this checkbox will be shown. All errors can be shown again if user is trying to submit the form without filling it. This issue happens when we are going to display the error list on the top of any form and the first element is mandatory checkbox.

I haven't found any patch for this issue. For now I have fixed this issue using custom implementation where form validator has been triggered manually. I will try to post one patch here if possible.

Please reopen this issue.

gobinathm’s picture

Reopening as requested by asamant6 in chat.