• Resolved mrpetreli

    (@mrpetreli)


    Hi

    Eg fieldname1 has dropdown options (1,2,3)

    How do I make fieldname100 & fieldname101 required only if fieldname1 option is selected as 1?

    • This topic was modified 7 years, 4 months ago by mrpetreli. Reason: forgot to tick a box
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @mrpetreli,

    In this case you will need a little of additional code.

    – Insert a “HTML Content” field in the form, with the following piece of code as its content:

    <script>
    jQuery(document).on('change', '[id*="fieldname1_"]', function(){
    if( jQuery(this).val() == 1)
    {
    jQuery('[id*="fieldname100_"],[id*="fieldname101_"]').addClass('required');
    }
    else
    {
    jQuery('[id*="fieldname100_"],[id*="fieldname101_"]').removeClass('required');
    }
    });
    </script>

    and that’s all.
    Now you simply should edit the previous piece of code to use the real fields’ names and the correct value in the comparison.

    Best regards.

    Thread Starter mrpetreli

    (@mrpetreli)

    Great you guys are the best.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Required Field’ is closed to new replies.