Issue with Displaying Constraint Message in Form Preview

Hello all,

I am currently working on a form in KoboToolbox and encountering an issue when testing it in the preview mode. I’ve set up a constraint for a question to limit responses to a maximum of 31, but it seems like the form is still accepting values greater than this.

Here is the configuration for the question in my XLSForm:

type      | name        | label                                | constraint | constraint_message
----------|-------------|--------------------------------------|------------|-------------------
integer   | pizzas_month| How many pizzas have you eaten this month? | .<=31     | Please enter a value 31 or less

In the form preview, when I input a value greater than 31 (for example, 50), I am expecting to see the constraint message (“Please enter a value 31 or less”). However, the form is still being validated and accepted with the higher value.

I’ve checked the form in a spreadsheet program, ensured that the question type is correct, and I’m confident that there are no extra spaces, incorrect quotation marks, or other formatting issues. I’ve also saved and re-uploaded the form to KoboToolbox after making these changes.

Does anyone have any ideas on why this constraint might not be working, or suggestions on what else I can try to resolve this issue?

Welcome @stefanwilliams878 ,
Did you re-deploy the form?
Did you try with preview in the online validator?
Did you try with current() ? See ODK XForms Specification
Did you try after removing the green colour at 31 ?

Hint: A constraint is not activated during focus being in the field, only after you leave the field or click on validate (depending on your Collect settings).

1 Like