how do i make 1 field OR another be required | Community
Skip to main content
Trish_Voskovitc
Level 5
October 3, 2013
Question

how do i make 1 field OR another be required

  • October 3, 2013
  • 1 reply
  • 568 views
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?
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

October 3, 2013
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.