Hello,
I am having some issues with the JavaScript that is in many posts to make a field required based on a previous value.
$(document).ready(function () { $('#q1 input').change(function () { if ($(this).val()=="Yes") { $('#q17 label').append('<span class="cf-required">*</span>'); $('#q17 input').attr('required', 'True'); } else { $('#q17 span.cf-required').remove(); $('#q17 input').removeClass('required').removeAttr('required'); } }) });
This issue I have is that it not only makes the question required but it also make both the radio button value required.
The way I want my process to work is that if the "Is there an abstract available for this property?" is answered yes then the question "Is this replacing an existing abstract?" needs to be required.
I have the field set to required and have it hidden (with field rules) until the available question is answered Yes.
Where the trouble is coming in is that I need to save the data from both fields even when they are hidden. So even if they choose No on the first question, if I leave validation on, it won't let them submit because it still says question 2 is required even though it is not shown.
So I tried to make the field required through JavaScript but that is where it is making too much of it required. How do I alter the script to not make the radio button values required.
Hope this make a little bit of sense.
Thanks.