Forums

Disable required fields

fastmax 22 Jan, 2015
Hi,
I build a form with a radio button that leads to two different fieldset , in each of them there are required fields .
I need to disable the fields of the fieldset that was not chosen, otherwise the module stops for lack of data required.
I tried using (in radiobutton edit) :
EVENT tab
On = name_radiobutton_selection DISABLE name_fieldset
but the fields become unusable but the module has the same problem .
If I configure the fields not required everything works fine.

I hope I explained myself
GreyHead 22 Jan, 2015
Hi fastmax,

I think that you'd need to do this by calling a JavaScript function that found and enabled/disabled the inputs in each fieldset.

Bob
BNDragon 22 Jan, 2015
Hi,

@Bob - Just disable the inputs set the fields not required to CF?

@fastmax - If disable the inputs set the fields not required to CF it's kind easy make it in JS like Bob suggest.
If you set one class to each fieldset input it become more easily. Assuming this, some like this should work:
$('#radiobuttonA').click(function ()
			 {
			 $('.fieldsGroupA').prop('disabled', true);
			 $('.fieldsGroupB').prop('disabled', false);
			 }
			 );


You can Hide it too if you want, adding
$('.fieldsGroupA').hide();
😉

BN
GreyHead 23 Jan, 2015
Hi,

In CFv4 disabled inputs aren't validated - I think that the same is true in CFv5 as well.

Bob
BNDragon 23 Jan, 2015
Hi Bob,

Thats great, thats really helpful🙂

BN
This topic is locked and no more replies can be posted.