Hello,
I'm trying to establish a constraint in Survey123 to restrict the allowable values in an integer field to only allow multiples of 0.25. The purpose of the field is for users to enter how much time they spent on an activity and we want it to be in 15 minute increments. I was able to get some different expressions to work on a browser but none of them worked using the survey123 app. Using a constraint would prevent any and all values from being accepted in the mobile app. Any value entered would result in a constraint violation in the survey123 mobile app.
Here are some of the different options I tried:
1) .25 * round(${mpHOURS} * 4) = ${mpHOURS}
2) (${mpHOURS}*4 - floor(${mpHOURS}*4)) = 0
3) regex(string(${mpHOURS}), '^\d+ (\.00|\.25|\.50|\.75)?$')
4) Javascript function
function isMultipleOfQuarter(value) {
var multiplied = value * 4;
return multiplied ===
Math.floor(multiplied);}
Additional Information:
Field type is decimal
published in Survey123 Connect version 3.18.123
Thank you!