Trim and Proper in Text question

@Grzesiek2010 @iamnarendrasingh

1. What is the problem? Be very detailed.
I have 2 text question, i.e. (Q1 and Q9) in which i am asking about brand and i want to validate text for both of the question. how could i validate it because in Q1 respondent enter "Computer" and in Q9 he enter "computer" then device gives an error. how could i validate case sensitive text and trim text in case of extra space there are some more possiblities

image

2. What app or server are you using and on what device and operating system? Include version numbers.
ODK Collect - ODK Aggregate - Android

3. What you have you tried to fix the problem?

4. What steps can we take to reproduce the problem?
you can make 2 text question and then constraint to validate text for both questions

5. Anything else we should know or have? If you have a test form or screenshots or logs, attach below.

Hi @noman.s2325

if you have a limited number of options, the best way would probably be to make a list in the choice sheet (or in support csv) so that typing errors are minimized and options are easier to compare.
You might want to allow text field only for "other" option.

Using text fields will always expose you to typing errors. A way to minimize them is to constrain the type of characters can be entered, for example by using regex to impose characters are always lower case and special symbols (including space) are not allowed.

Errors like computer/comupter will still be possible, though.
You might have to do data cleaning afterwards. In Stata you can use commands like soundex or matchit

You might want to check a similar discussion in a previous post in the Forum:

I hope this helps!

Best,
Andrea

You can probably accomplish both using the (new) translate() function. First, convert your input string to, say, all lowercase with something like:

translate(${input}, 'ABCD...', 'abcd...')

To get rid of any leading/trailing/embedded spaces:

translate(${input}, ' ', '')

(you can actually combine these into one operation...)

That said, I agree with @Andrea_Martin that if there are very specific, limited inputs that you need to check against, use select_one choices instead of free-form text entry.

1 Like

Thanks @Xiphware for your response, could you please share some sample file please..

Have a play around with this:

sanitise.xls (24 KB)

It'll 'sanitise' your input text to make it all lowercase and remove any leading/trailing/embedded spaces. You can then use this result for subsequent comparisons.

2 Likes

I helped get normalize-space into ODK. It removes leading and trailing spaces and it makes all sequences of interior whitespace into a single space.

1 Like