Add restriction on text field

Dear ODK Team,

I want to add restriction on my text field like that:
5numbers-7numbers-1number
Example:
32345-0805467-5

Will be very greatful to ODK Team.
Regards,
Tasadduq Husssain

Use a regular expression (https://docs.opendatakit.org/form-regex) as a constraint.

I haven't tested it, but regex(.,'^[0-9]{5}-[0-9]{7}-[0-9]{1}$') should work.

1 Like

Thanks Sir,
I ho I Will work..
Please tell me I can add this restriction on numeric field or I will work on text field?

Regards,

I'd recommend you use a text field with the numbers appearance. https://docs.opendatakit.org/form-question-types/#number-text-widget has more.

1 Like

Thanks Sir.
I am very thankful to you...

Regards,

Dear Yaw Anokwa,

regex(.,'^[0-9]{5}-[0-9]{7}-[0-9]{1}$)')
It's accepting numbers regarding the above format and not showing any wrong message.

Please guide me.

Regards,

There is a ‘)’ after the ‘$’. Remove it.

Thanks,I will and inform you sir..