CalcBuilder Forum

How to create a script to check if all values of a group of fields are entered.

User 2017-03-18 17:58:40


I am trying to create a script to check if all values of certain fields are entered.
I tried to used PHP, but I cannot get it to work:
$fw1 = floatval($w1);
$fh1 = floatval($h1);
$ft1 = floatval($t1);
if (( $fw1 != 0 ) Xor ( $fh1 != 0 )) or (( $fw1 != 0 ) Xor ( $ft1 != 0 )) or (( $fh1 != 0 ) Xor ( $ft1 !=0 )) {
echo 'Please enter all three dimensions';

In essence, what I am trying to do is in case the user has entered values to some of the 3 fields w1:Width, h1:Height, or t1:Thickness, I would like the script to ask them to enter all dimensions, so it should not finish the calc but should wait for the data entry. In case they did not enter any if the values, the script should not ask them anything and the calculation should take place.

Thank you in advance.

Moonsoft support 2017-03-20 20:35:39

not sure if creating the validation at server side would be the better approach, we'd suggest instead to add some code at the javascript tab (before calculate execution tab), so the calculation won't be launched at all until your conditions are met:

var w1=CB("input").val();
var h1=CB("input").val();
var t1=CB("input").val();

//if any of the fields is not empty

//then if any if the fields is empty

//message and abort calculation
alert('Please enter all three dimensions');
return (-1);


If creating the php code is a must for your specific case you should return the message 'inside' any result, so users can see it at the page, you can use any output variable and/or any inline result to print it inside the input form. So, intead of the 'echo' function, you should write something like

$mymessage="Please enter all three dimensions";

And then print ##mymessage## at the output form.

Please let us know if you need further help.

User 2017-03-21 16:16:57

Thank you very much. I went with the javascript approach.

List Manager

Build different lists for your site

Buy now!
Support/development 40 hours

With the peace of mind of having a professional team at your service (20% discount)

Buy now!