Partially pre-filling text response

Hi all,

Relatively new ODK user here. I have searched in vain on the forum and elsewhere for similar issues, and am surprised not to find this is a common question.

I am using xlsform to create a form that includes a "text" type question. The question prompts the user to enter a phone number, for example 0123456789. However, I would like to instead encourage this same number to be entered as 012-345-6789, in order to avoid cases that are sometimes entered with and without hyphens. So, I am wondering how I might set up the form so that the "-" characters appear automatically in the entry prompt, and then the text fills in around them. For example, the response box would start with something that looks like: -_-_____

I am running ODK collect v1.22.3 off of an Android phone/tablet.

Thank you in advance!

That is not possible.

A workaround will be to use regex function to enforce that format and use a hint to provide instructions.

https://docs.opendatakit.org/form-regex/

2 Likes

Thank you for the advice!

Would another possible solution be to place 3 integer response prompts next to each other? So for a number separated by hyphens, for example, it might look like:

xxx . / . xxx . / . xxxx
____ . ____ . _____

But I am not sure if it would be possible to create a format like that. Is it possible to design something like this (which would then record each segment as a separate variable)?

Thanks again!

It's not possible to add three integer fields like you described.

@LN what about adding new phone question (or appearance for text questions) to solve such issues? It could look like her:

Yes exactly that would be so useful! Would be very helpful if it were somewhat flexible on formatting for dates, phone numbers, or generic ID #'s that can easily get confused if enumerators choose to either omit or include separating characters.

Thank you for looking into this!

Hi again,

Just to follow-up, does this seem like something that would be relatively simple and realistic to implement? The example that Grzesiek2010 suggested would be perfect. Thanks,

Tom

I agree that if a new appearance were added, there would immediately be requests to configure it in different ways. If a contributor wanted to design a specification for this and implement the feature, it would likely be welcome. There may be some overlap with Form design: grid of text or numeric input which also relates to adding flexibility to how text fields are displayed in relation to each other.

In the mean time, I would strongly recommend the regex approach, @ThomasKraft. You can even include a warning on the same screen to make it easier for users to follow. See this example form in which a red error message is displayed until the desired format is used.

Thank you @LN, I'll use the regex approach for now.

1 Like