Check divisibility of result [RESOLVED]

I created a small form with the fields
num1
num2
num3 (set to 22)
sum

I would like to check if the sum can be divided by 4 and output a corresponding message. I know I can check a number with php and something like

<?php
	$num = sum field with ID 5 goes here;
	
	if ($num % 4 == 0) {
		echo "Die Gesamtzahl kann durch 4 geteilt werden";
	}
	else {
		echo "die Gesamtzahl kann nicht durch 4 geteilt werden";
	}

?>

How can I implement that into the form? Is that possible?

To incorporate that check into the form, you can use the gform_field_validation filter:

If you have any other questions, please let us know.

Thank you very much! Worked perfect :slight_smile:

1 Like