Apply required attribute to multiple choice elements

Home Forums Quform WordPress Apply required attribute to multiple choice elements

This topic is: not resolved
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #20783
    darkspark
    Participant

    Hi Ally,

    I’m having a problem with setting the required attribute on multiple choice elements via PHP.

    What I have are three multiple choice elements contained in a group that is initially hidden on load via JS. I have two checkboxes: If I click on the 2nd checkbox, the hidden group is displayed.

    The required attribute should be applied to the multiple choice elements if the 2nd checkbox is checked and vice versa.

    I’m using the code below to set the attribute, but somehow I couldn’t get it to work


    function my_set_fields_required($form)
    {
    if ($form->getValue('iphorm_177_72_2') == 'Ex-U.S. stock markets') {
    $form->getElement('iphorm_177_73')->setRequired(true);
    $form->getElement('iphorm_177_76')->setRequired(true);
    $form->getElement('iphorm_177_77')->setRequired(true);
    }
    }
    add_action('iphorm_pre_process_177', 'my_set_fields_required');

    I’ll send you the link to the form via email.

    Thanks for looking into this!

    #20795
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #20833
    darkspark
    Participant

    Hi Ally,

    Never realized there was a much more simpler solution! Got it to work. Please mark as solved.

    Thanks again!

    Darkspark

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy