conditional fields events

webredhand 05 Feb, 2015
Hi, I made a form in which a field 'Student' with two radiobuttons: 'no' and 'yes'.
If you click 'yes', a new field comes up, in which you can upload a file.
The field 'Student' is validated as required
in the Event-tab I've set this:
see the attached image
It all works fine.
But when I validate de upload-field as required, I can't submit de the form anymore if I click the 'no'-button in the field 'Student'.
What can be wrong?
Thank you in advance
GreyHead 05 Feb, 2015
Hi webredhand,

I don't think that CF handles hidden required inputs very well. It should disable them or remove the validation when they are hidden and that doesn't happen. When I have needed to do this I've ended up hand coding the JavaScript. Here's an example that hides/shows two divs in the form page
jQuery(document).ready(function (jQ) {
  /* JavaScript to hide and show elements on the Checkout page*/
  jQ('input[name=gateway]').change(function() {
    if ( jQ('input:radio[name=gateway]').is(':checked') ) {
      var gateway = jQ('input:radio[name=gateway]:checked').val();
      switch (gateway) {
        case 'pp_d':
          jQ('#gateway_pp_d').show();
          jQ('#gateway_anet').hide();
          jQ('#gateway_anet input').prop('disabled', true);
          jQ('#gateway_anet select').prop('disabled', true);
          break;
        case 'anet':
          jQ('#gateway_pp_d').hide();
          jQ('#gateway_anet').show();
          jQ('#gateway_anet input').prop('disabled', false);
          jQ('#gateway_anet select').prop('disabled', false);
          break;
      }
    } else {
      jQ('#gateway_pp_d').hide();
      jQ('#gateway_anet').hide();
    }
  });
  jQ('#gateway_pp_d').hide();
  jQ('#gateway_anet').hide();
});

Bob
webredhand 05 Feb, 2015
Hi Bob, thank you for your very quick answer.
I'm a newbee at CF and JS is mostly abracadabra for me.
So I don't understand much of your answer.
Nevertheless I try hard, and that's why I've at least three questions:
1. where do I have to put this code?
2. is 'gateway' the name of the field with the radiobuttons, so do I have to put instead of 'gateway' the name of my own radiobuttonfield?
3. I don't see a relation to the secondary field, i.e. the field to upload a file. How is that?
I hope you don't mind I maybe ask silly questions.
Max_admin 06 Feb, 2015
Hi webredhand,

If the only problem you have is the hidden field validation then a new update is expected soon which will fix this issue.

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.