Popular Help ContentNo popular content.
- For a basic validation condition you can use the Expression Builder, which is described in the Beginner Tutorial.
- Whenever you are referring to the value of the question to which you are adding the validation condition, you will see the question referred to as "."
- Common components of a validation condition might be the use of = , >, and <. For example:
- . > 8 (the response must be greater than 8)
- . =! 0 (the response cannot be 0)
- . > 1 and . < 10 (the response must be greater than 1 and also less than 10)
- Restricting the length of a numeric ID or text field you can use the function string-length() (for more information on functions see CommCare Functions)
- To require a specific length (example: 8 characters long): string-length(.) = 8. NOTE: This length count includes spaces.
- To restrict the length of a string to a range of characters (example: 7-9 characters long): string-length(.) >=7 and string-length(.) <=9
- To validate a date relative to today's date you can use the function today():
- Restrict a date entered so that it cannot be in the future (must be today or earlier): . <= today()
- Restrict a date such that it must be within the previous 10 months (305 days): . > today() - 305 and . <= today()
- To require the user to enter in a text entry question in a specific format, you can use various regex functions.
- Requires the first letter be capitalized, and all other letters be lowercase: regex(., "^[A-Z][a-z]+$")
If you want to create complex expressions please see Advanced Validation Conditions.