Add numeric constraints to barcode

Hello Good People,

I have a KOBO form which is to collect Beneficiary Data Collection using their ID Card. ID Card has two barcodes. One is the beneficiary’s numeric ID Number which is we intend to collect (e.g. - “1777690765512”). Another is their track number which has text on it. (e.g- “PHY-1999222” ) which we do not need to collect. I want to add a constraint to the barcode field so that if anyone scan the track number it will show an error message. Please note that the numeric ID Number has a range of lengths, from 6 digits to 21 digits.
Is there any way to add constraint which only allows scanning numeric number and if the scanned barcode has text in it, it will show an error?

Welcome to the community @rifat_iom! Have you gone through our post discussed previously on how to pull data though a predefined barcode (it should help you):

Besides, here is also a post that deals with barcode constraints:

Thanks Kal_Lam,

Actually I am not looking for Pull data. Data will be collected in the field using Odk Collect app. We don’t have any previous database for the data.

It’s OK. Maybe the second post shared above should help you solve your issue.

You can use the following constraint in the barcode question.


This will ensure that only numeric values are accepted in the barcode question.


Hi @ks_1,
I noticed that your constraint did not seem to work as expected.


Given that you are sure that your ID will be a number, I would suggest creating a simple constraint such as .>=1

This will only allow for the barcode scanned to be a number. If you know the length of the numeric ID, as 6 and 12 in this case, you can also play with your constraint to be .>=99999 and .<=1000000000000


1 Like

Thanks to all your help. I found a constraint that solved my problem which is -


1 Like