Home › Forums › Quform WordPress › Minimum and maximum selected checkboxes › Reply To: Minimum and maximum selected checkboxes
I also modified the code by changing the IDs, but unfortunately when I press the submit button the condition does not work and the total is not checked if it is equal to 100 or not
This is the code I modified the IDs and added to Code Snippets:
add_filter(‘quform_post_validate_141’, function (array $result, Quform_Form $form) {
$ids = array(‘141_11’, ‘141_19’, ‘141_29’, ‘141_40’, ‘141_50′,’141_60′,’141_70′,’141_150’);
$total = 0;
foreach ($ids as $id) {
$element = $form->getElement(“quform_$id”);
if ($element instanceof Quform_Element_Field && !$element->isEmpty()) {
$total += (int) $element->getValue();
}
}
if ($total > 100) {
$result = array(
‘type’ => ‘error’,
‘error’ => array(
‘enabled’ => true,
‘title’ => ”,
‘content’ => ‘Total goal importance ratio cannot exceed 100’
)
);
}
return $result;
}, 10, 2);
Any advice?