if checkbox empty

Home Forums Quform WordPress if checkbox empty

This topic is: not resolved
  • This topic has 4 replies, 2 voices, and was last updated 7 years ago by moe.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #21046
    moe
    Participant

    Hi there
    We have a question about we need to make check up if all the fields empty so the user have to accept that by clicking on checkbox, otherwise if the fields not empty so they don’t need to accept.

    Is that possible ?

    http://www.skraldgodt.dk/toemnings-bestilling/

    Awaiting for your kind response.

    Moe

    Attachments:
    You must be logged in to view attached files.
    #21069
    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.

    #21084
    moe
    Participant

    Thanks Ally

    I did this exactly like your code with the rights fields and form ID’s but it didn’t work.
    Could you please check if it’s right and why it didn’t work.

    
     
     function my_checkbox_required($form)
    {
        $checkbox = $form->getElement('iphorm_11_64');
    
        if ($checkbox && $checkbox->isEmpty()) {
            $checkIfEmpty = array('iphorm_11_10', 'iphorm_11_11', 'iphorm_11_12', 'iphorm_11_13', 'iphorm_11_14', 'iphorm_11_15', 'iphorm_11_30', 'iphorm_11_16', 'iphorm_11_17', 'iphorm_11_18', 'iphorm_11_19', 'iphorm_11_20', 'iphorm_11_21', 'iphorm_11_22', 'iphorm_11_23', 'iphorm_11_44', 'iphorm_11_46', 'iphorm_11_40', 'iphorm_11_52', 'iphorm_11_50', 'iphorm_11_46', 'iphorm_11_56', 'iphorm_11_62', 'iphorm_11_63');
            $hasValue = false;
    
            foreach ($checkIfEmpty as $elementId) {
                $element = $form->getElement($elementId);
    
                if ($element && ! $element->isEmpty()) {
                    $hasValue = true;
                    break;
                }
            }
    
            if (!$hasValue) {
                $checkbox->setRequired(true);
            }
        }
    }
    add_filter('iphorm_pre_validate_1', 'my_checkbox_required', 10, 3);
    

    form link her

    Awaiting for your kind response.
    Moe

    • This reply was modified 7 years ago by moe.
    Attachments:
    You must be logged in to view attached files.
    #21092
    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.

    #21099
    moe
    Participant

    Thanks a lot 🙂

Viewing 5 posts - 1 through 5 (of 5 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