Home › Forums › Quform WordPress › Checkbox required
- This topic has 6 replies, 2 voices, and was last updated 6 years, 4 months ago by moe.
- AuthorPosts
- December 4, 2017 at 11:31 am #23314moeParticipant
Hi
We have did a solution earlier to make checkbox required if the fields are empty.
We just want to add small thing on it:
if the one or all of the fields are filled then user can’t click on checkboxis that possible ?
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); } } }
- This topic was modified 6 years, 4 months ago by Ally. Reason: Code formatting
December 8, 2017 at 12:53 pm #23395AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
December 8, 2017 at 1:11 pm #23399moeParticipantThanks Ally
But it didn’t works
you can see the page her http://www.revas.dk/toemnings-bestilling/Am still able to click on checkbox even i filled the fields
December 11, 2017 at 2:29 pm #23448AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
December 12, 2017 at 7:15 am #23475moeParticipantThanks but still didn’t work :/
am still able to click on check box even the fields are filledDecember 13, 2017 at 2:01 pm #23497AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
December 13, 2017 at 2:08 pm #23498moeParticipantHi Ally
It’s worked perfect
thanks a lot
- AuthorPosts
- You must be logged in to reply to this topic.