- 1 Minute to read
- Print
- DarkLight
- PDF
How do I use Validation Logic with my Form Fields?
- 1 Minute to read
- Print
- DarkLight
- PDF
By default, all fields on a form are required before the submission can be submitted. If you would like to make some fields optional or add logic to make them conditionally required, you can use the Validation Logic formula field.
If you used the tool to create your form from a PDF, the Validation Logic formula field will be blank. If you added a component by dragging it onto the canvas, your formula field will look like the image above. Leaving the Validation Logic formula field blank or using our helper function to make this field required both have the same effect of requiring the field.
The helper function below is the function you can use to require a field. Please note: the word "value" is used to let a component refer to itself so you can use this formula exactly as written.
isRequired(value)
The other commonly used helper function makes a field optional. This is helpful for information that is nice to have but shouldn't stop a submission if it isn't present. Note: this helper function does not need to reference the word "value" or any ID.
isOptional()
There are a number of other helper functions as well as other Javascript that could be useful to create custom Validation Logic formulas.
isEmail(value)
withinRange(value, min, max)
equals(expected, actual)
notEquals(expected, actual)
isGreaterThan(num1, num2)
isGreaterThanOrEqualTo(num1, num2)
isLessThan(num1, num2)
isLessThanOrEqualTo(num1, num2)
and(val1, val2)
or(val1, val2)
includes(list, value)
toCurrency(number) => string
fromCurrency(string) => number