I basically want the form to check to make sure there are no more than 200 attendees and if so to throw a message/warning saying "too many please go back and amend your entries"There are 7 text fields shown above that cannot be greater than 200 and also their total sum cannot be also greater than 200.Alsowould it be possible to have those 7 fields automatically add up and show the final number in another field (e.g. as number are put in another field in real time displays that numbers and the sum of the other 7 fields?) Thanks."> Custom Server Side Validation - Forums

Forums

Custom Server Side Validation

KaKoRoT 24 May, 2012
Hi,

I wonder if you can point me in right direction, I have put in a "Custom Server Side Validation" with a On Fail Event Loop.

The code in the Validation is
<?php

$all_attendees = $age_range_0_5 + $age_range_6_12 + $age_range_13_18 + $age_range_19_25 + $age_range_26_35 + $age_range_36_50 + $age_range_50_plus;

if ($all_attendees > 200;){
	echo("Too many attendees");
}
?>


I basically want the form to check to make sure there are no more than 200 attendees and if so to throw a message/warning saying "too many please go back and amend your entries"

There are 7 text fields shown above that cannot be greater than 200 and also their total sum cannot be also greater than 200.

Also
would it be possible to have those 7 fields automatically add up and show the final number in another field (e.g. as number are put in another field in real time displays that numbers and the sum of the other 7 fields?)

Thanks.
GreyHead 24 May, 2012
Hi KaKoRoT,

Please check the Help on the Custom Serverside Validation action for the correct syntax to use (but note that 'errros' should be 'errors').

The form data is available in the $form->data array e.g. $form->data['age_range_0_5']

Bob
This topic is locked and no more replies can be posted.