# I want to collect ID card number for any 4 listed ID cards available to the respondents but each of the cards has different number of digits

I wish to use multiple constraints in a particular question. I want to collect ID card number for any 4 listed ID cards available to the respondents but each of the cards has different number of digits.

For example, one card is alphanumeric with 19 digits, another is number only with 11 digits. I want to ensure that the correct digits is inputted for any of the cards

Welcome to the community @Bilqis! You could do this as outlined in our support article Restricting Text Responses With Regular Expressions. As a sample workaround you could also have a look to the following community post discussed previously.

This post discussed previously should be very relevant to solve your issue:

I had used the options listed above, it isnβt working. It works for numbers only.

Specifically, I am working with 4 different cards with the following characteristics. Only one card can be selected, however, I want the specific constraints of each to apply when any of them is selected

ID Card - alphanumeric 19 digits
ID card 2 - alphanumeric with 9 digits
ID card 3 - alphanumeric with 12 digits
ID card 4 - numbers with 11 digits

Thank you

Hello @Bilqis,
You can do this by using a (cascading) if clause in your constraint, based on the selected card type (preceding select_one question).
Like:
if( \${cardType} = β1β, regex β¦ A, if(\${cardType} = β2β, regex β¦ B, if( β¦, regex β¦C. if(β¦, regex D, false()) ) ) )

(You might also use 4 different ID variables, filtered by relevant clause, based on the chosen type chosen.)

1 Like

Kindly check if this constraint is in order
if(\${valididtype} = β1β, regex(.,β^[0-9]{11}\$β), if(\${valididtype} = β2β, regex(.,β^([A-Z0-9, ,-]){1,9}\$β), if(\${valididtype} = β3β, regex(.,β^([A-Z0-9, ,-]){1,12}\$β), if(\${valididtype} = β4β, regex(.,β^([A-Z0-9, ,-]){1,19}\$β), false()) ) ) )

Kindly check if this constraint is in order
if(\${valididtype} = β1β, regex(.,β^[0-9]{11}\$β), if(\${valididtype} = β2β, regex(.,β^([A-Z0-9, ,-]){1,9}\$β), if(\${valididtype} = β3β, regex(.,β^([A-Z0-9, ,-]){1,12}\$β), if(\${valididtype} = β4β, regex(.,β^([A-Z0-9, ,-]){1,19}\$β), false()) ) ) )

@Bilqis, you could do it as outlined in the image shared below:

#### Reference XLSForm:

Regex.xlsx (12.8 KB)