Home › Forums › Quform WordPress › if checkbox empty
- This topic has 4 replies, 2 voices, and was last updated 7 years ago by moe.
- AuthorPosts
- April 5, 2017 at 11:30 am #21046moeParticipant
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.April 6, 2017 at 3:27 pm #21069AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
April 10, 2017 at 12:46 pm #21084moeParticipantThanks 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.April 10, 2017 at 4:45 pm #21092AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
April 11, 2017 at 7:34 am #21099moeParticipantThanks a lot 🙂
- AuthorPosts
- You must be logged in to reply to this topic.