Specify a masking pattern for an ID question

I am building a survey using XLSForms and I have a question of type “text” that will receive ID numbers. These numbers are composed of 16 digits grouped into blocks like this #-####-#-#######-#-##.

In the constraint column, I have put the right regex so that users can’t input more or less than 16 digits. In the appearance column, I have put numbers so that only the numeric keyboard is shown during data entry.

Now, my question is: can I make sure the form would automatically insert these dashes when the user is doing input?
These dashes are not part of the data, they are just a visual guide to minimize typos.

ChatGPT says there is a new feature called “input masking” introduced recently in KoBoToolbox version 2.024.27 where such thing can be done. Any more info?
I can’t find this feature documented anywhere in the tutorials.

1 Like

Welcome to the community, @gashakamba!

You will need to input the dashes too. You should be able to make your own regex code by following this support article Restricting Text Responses With Regular Expressions.

Hello @Kal_Lam I like how you reply to many questions on this forum. Thanks for the dedication.
Now, I have read many of your responses to questions similar to this and you seem to always suggest the same thing even to cases that are a bit dissimilar.
For instance, I have further dove deeper into this particular issue and I have found that one can’t basically achieve this functionality with Kobo.
Using regex() to restrict text responses is quite different from my question and I indeed am already extensively using these types of constraints in my form.

1 Like

Hi, I used this method and it worked for me. I hope it helps you.

Automatically displaying unique ID number

1 Like

You cant. And ChatGPT is wrong if it told you otherwise.

There is no way to dynamically reformat what the user is typing while they are typing it in, in either the Enketo or KoboCollect form entry clients.

What you can do, however, is either require the user to insert the necessary dashes in the right place, and then check the format is correct using a regex(). Or you can have the user typing in just the (16?) digits (without dashes!), and then use a calculation with the substr() function to extract the numbers for each block, and the recombine them with a ‘-’ delimiter between each block using concat() into your correctly formatted ID format for submission.

1 Like