In OFS Flow validations, OFS will read 0 and empty fields as the same. This article guides you through using regex to differentiate between the two.
Example 1.
- Valid if the field is = 0
- Error if the field is = empty
Building the validations
Step 1 - Create the Decimal field
- Drag in the icon from the left
- Enter a Unique Field Name
Step 2 - Click the 'Field Validation Rules' tab and drag in the value field from the right and drop it into the empty space
Step 3 - Click on the 'Valid' word
Step 4 - Set up the Form Status, Colour and add a message if needed.
Note: The Error status will not allow the user to submit the form until the field is valid.
Step 5 - Enter the following validation in the bottom blank area
data["field"]=~"^$"
- Error is the Field is empty
Step 6 - Create another validation for the valid field and set up the status, colour and message.
data["field"]>=0
- Valid if the field is greater than or equal to 0
Example 2.
- Selection Box = Yes or No
- Integer Field = numbers or can be empty
- Valid when the Selection Box field is Yes and the field is 0,
- Error when the Selection Box field is Yes and the field is empty
- Valid when the Selection Box is No and empty
Building the validations
Step 1 - Create the Selection Box field
- Drag in the icon from the left
- Enter a Unique Field Name
- Click the '+' button and add the values
Step 2 - Create the Integer field
Step 3 - Drag in the value field from the right and drop it into the empty space
Step 4 - Click on the 'Valid' word
Step 5 - Set up the Form Status, Colour and add a message if needed.
Note: The Error status will not allow the user to submit the form until the field is valid.
Step 6 - Enter the following validation in the bottom blank area
(data["Selection Box"]=="Yes")&&(data["Field"]=~"^$")
- Error if the Selection Box is Yes and the Field is empty
Step 7 - Create another validation for the valid field and set up the status, colour and message.
data["Field"]>=0
- Valid if the field is greater than or equal to 0