Validation of text entry in multiple choice questions | XM Community
Solved

Validation of text entry in multiple choice questions


Hi,

Is there any way to set minimum character requirements for the text entry boxes (which show up if you select allow for text entry) in multiple choice questions? the options are quite different from a regular textbox question.
icon

Best answer by bstrahin 9 August 2018, 22:05

View original

16 replies

Thanks! How do you set minimum characters requirements? In a regular textbox, you will have an explicit option for that. I don't seem to find it here.
Userlevel 7
Badge +38
@hessam01 the minimum length is a built in validation for text entry question types. See screenshot. If this is very important to you, then you can have this show up as a follow-up question (display logic) to your your multiple choice question. If you just want to make sure they enter something (e.g. len > 0) then you can follow @Kate's screenshot and choose force response.

!
Thanks for your response. I prefer to have the text beside the checkbox in the same question. I found the following option (see the screenshot) on custom validation. Do these apply to text values?

Thanks in advance!

!
Userlevel 7
Badge +38
I agree that having the box with the check option is much easier for the respondent. If you are only interested in that they don't leave the box blank, I would not use custom validation but rather the feature that Kate pointed out. This will be much more simple for you to program. You would choose to "force response" in her screen shot above.

This then allows all of the following scenarios:
* If the box is not checked, the text field can be left blank and advance
* If the box is not checked but there is text in the field Qualtrics automatically throws an error
* If the box is checked and the text field is empty, it will not advance until the respondent types something in the box.
Hello @hessam01 ,

Choose "Matches regex" from the custom validation option and in the last box paste the following code(without quotes): "[A-Za-z]{5}" where 5 is minimum character requirement
Thanks bstrahin, Shashi, and Kate for your great help on this.
> @Shashi said:
> Hello @hessam01 ,
>
> Choose "Matches regex" from the custom validation option and in the last box paste the following code(without quotes): "[A-Za-z]{5}" where 5 is minimum character requirement

In case you want space, comma, dot, question mark, exclamation use this "[A-Za-z,.!? ]{5}"
customize accordingly.
> @Shashi said:
> Hello @hessam01 ,
>
> Choose "Matches regex" from the custom validation option and in the last box paste the following code(without quotes): "[A-Za-z]{5}" where 5 is minimum character requirement

Thanks for your response! How can I do that for each of the textboxes. The custom validation works at the question level, not the option level. So basically, what I want to do is that if a respondent selects each of the idea boxes then he/she will be required to enter at least a 50 character description. This is the screenshot for your reference.

Thanks in advance!

!
> @hessam01 said:
> > @Shashi said:
> > Hello @hessam01 ,
> >
> > Choose "Matches regex" from the custom validation option and in the last box paste the following code(without quotes): "[A-Za-z]{5}" where 5 is minimum character requirement
>
> Thanks for your response! How can I do that for each of the textboxes. The custom validation works at the question level, not the option level. So basically, what I want to do is that if a respondent selects each of the idea boxes then he/she will be required to enter at least a 50 character description. This is the screenshot for your reference.
>
> Thanks in advance!
>
> !
>
>
>

Suppose you have 3 options then the conditions will be as shown in the image.
!
Userlevel 7
Badge +27
The correct regex for any 50 characters or more is `^.{50,}$`
> @Shashi said:
> Hello @hessam01 ,
>
> Choose "Matches regex" from the custom validation option and in the last box paste the following code(without quotes): "[A-Za-z]{5}" where 5 is minimum character requirement

Thanks @TomG ,
The correct regex is "^[A-Za-z]{50,}$"
Userlevel 7
Badge +27
> @Shashi said:
> > @Shashi said:
> > Hello @hessam01 ,
> >
> > Choose "Matches regex" from the custom validation option and in the last box paste the following code(without quotes): "[A-Za-z]{5}" where 5 is minimum character requirement
>
> Thanks @TomG ,
> The correct regex is "^[A-Za-z]{50,}$"

That will only allow letters (no spaces, punctuation, numbers, etc.). That probably isn't what @hessam01 wants. The regex I provided will allow for any characters.
Hi all,

It is me again having a question. I tried the following code (to accommodate different types of characters but still receiving an error even when I put more than 50 characters in the boxes. It only works when I put alphabetical characters. Any solution?

^[A-Za-z,.! ?/:;'"@#$%^&*()1234567890{50,}$

This is the screenshot

!




Thanks!
Userlevel 7
Badge +27
@hessam01,

Any of these special characters:
```
[\\^$.|?*+(){}
```
have to be escaped with a \\ in front of them.

Respondents aren't going to know what characters they can use and not use so, I think you would be better off just using the regex I gave earlier:
```
^.{50,}$
```
It seems like @Kate's comment has disappeared. Can someone re-post/re-explain it? I too would love to know how to simply force a respondent to enter text if they select an option which has a text entry next to it.
Userlevel 7
Badge +27
> @ADGA said:
> It seems like @Kate's comment has disappeared. Can someone re-post/re-explain it? I too would love to know how to simply force a respondent to enter text if they select an option which has a text entry next to it.

Select force response from the menu attached to the answer option:
!

Leave a Reply