how do i make 1 field OR another be required

Trish_Voskovitc
Level 5

how do i make 1 field OR another be required

i want to have 2 fields on a form but  set it up so that only 1 of the fields is required- if they fill out question A they don't have to do B or if they fill out B they don't have to do A.  but they have to do one or the other.
does anytone know how to do this or if it can even be done?
Tags (1)
1 REPLY 1
Anonymous
Not applicable

Re: how do i make 1 field OR another be required

That can be achieved through JavaScript/jQuery.

The code will be similar to

<s c r i pt>
        $(document).ready(function (){
            $("#input_b").change(function() {
                if ($(this).val() != "") {
                    $("#input_a").show();
                }else{
                    $("#input_a").hide();
                } 
            });
        });
</s c r i p t>
 
* spaces added to the word "script" to avoid the portal interpreting as a script.