When using Device Magic, it is sometimes useful to validate an answer for a certain field. When you set a validation rule, a form may not be submitted until the correct answer has been entered for that field. Below, I show you how to set this rule.
Firstly, open the form builder and select the question in which you'd like to validate. Then, select the 'Show Advanced Settings' checkbox.
Next, click the 'Validate Value' checkbox. You can then choose the condition for your answer by clicking 'set rule'.
Next, change the field to the one desired by selecting it from the drop down. For this example I chose ">" in the drop down menu to the right of the "Change field" link. Lastly, I typed in "2".
After clicking save, I typed the error message that I wanted to appear when a number greater than "2" was not submitted within the form.
When the question is filled in with a quantity less than 2 on a mobile device, a box will pop up notifying you with the error message. You will need to re-enter the answer correctly in order to be able to submit the form.
Date Validation
For simple checks such as ensuring a date is after, before, or equal to another date you can use the standard Validate Value rule:
Open the date field in the Form Builder.
Check Show Advanced Settings → Validate Value → Set Rule.
Choose the comparison operator (e.g., >, <, >=, <=) and select another date field or a fixed date.
Example:
{event_date} >= today()to ensure the date is today or in the future.
Enter the error message (e.g., “Please select a date that is today or later”).
Advanced Date Validation (Using Calculated Questions)
Use this method when you need more complex date logic, such as date ranges or multi-date relationships.
Steps
Add a Calculated Question to your form.
Check Hide this question so it doesn’t appear to the user.
Enter an expression such as:
Future date required:
{date_field} > today()End date must be after start date:
{end_date} >= {start_date}Date must be within a specific range:
({date_field} >= today()) AND ({date_field} <= today() + 30)
The result will be:
1 (true) if the condition is met
0 (false) if it is not
Go back to your Date Field → Advanced Settings → Validate Value.
Click Set Rule, choose your calculated question, and validate that its value equals 1.
Add a custom error message, such as:
“The selected date must fall within the allowed range.”
When the form is submitted on a mobile device, the validation will run and block submission if the condition is not met.
NOTES:
- The conditions you set up must be met (true), in order for the user to be able to submit the form.
- Validations will only be checked once the user clicks the "Submit" button.
- For more complex validations, check out this article here.
Other Useful Articles:
If you have any questions or comments please send us a message at support@devicemagic.com.om.



