Multiple Conditions - order of hierarchy

Options


I have a webform asking the user to enter a project, and I have an Instructions field underneath it to act as a validator, to make sure the user is entering the correct number. Project numbers are 10 digits, and start with the number 4. So I have the above as the three conditions for this instructions field. The first two conditions work (the Instruction field comes up if the number is too short or too long), but the Instruction field is there when the entry is blank (empty). I am wondering why this does that, because the third condition says "not empty." What is the hierarchy of the conditions? Are we able to "nest" the conditions? Thanks!

Tagged:

Answers

  • Tom_121527
    Options

    Hi @Kevin_347987, when your fields["project-number"] field is empty, it's actual value will usually either be null or an empty string. In both of those cases your fields["project-number"] is less than 4000000000 condition will evaluate to true.

    This screenshot shows how I believe the JavaScript runtime is actually evaluating your condition under the hood:

    You are not able to nest conditions and they're evaluated left to right. Also the AND condition takes precedence over OR so the conditions on either side of the AND operator are evaluated first, then the OR is evaluated. I believe you can accomplish what you're looking to do adding an additional and fields["project-number"] is not empty condition associated to the fields["project-number"] is less than 4000000000 condition.

    I would also encourage you to see if our Field Entry Validation feature is able to do a better job of validating the field data than the conditional instruction field approach. You should see an Entry Validation section available on the Basic tab of the Field Configuration form.