- Posts: 7
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Can i limit the answer to certain format or no. of characters?
- wendyt
- Topic Author
- Offline
- New Member
Less
More
6 years 7 months ago #157690
by wendyt
Can i limit the answer to certain format or no. of characters? was created by wendyt
Dear fellows,
I'd like to ask for mobile phone in numerical input/short free text but would like to limit (or validate) the response to 8 characters. I can only do it by setting maximum characters of 8 but this won't help to warn answers with fewer than 8 characters (digits).
Can it do this with "Validation"? If yes what shall i type there?
Thanks so much.
I'd like to ask for mobile phone in numerical input/short free text but would like to limit (or validate) the response to 8 characters. I can only do it by setting maximum characters of 8 but this won't help to warn answers with fewer than 8 characters (digits).
Can it do this with "Validation"? If yes what shall i type there?
Thanks so much.
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12790
- Thank you received: 3940
6 years 7 months ago - 6 years 7 months ago #157697
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Can i limit the answer to certain format or no. of characters?
Hi, wendyt,
you can use regular expression for that.
See all these examples:
manual.limesurvey.org/Using_regular_expressions
Maybe the expression of your desired phone format is already there.
So, in your survey you are looking for exactly eight digits?
Start with "0" is allowed?
Something like:
/^[0-9]{8}$/
Not allowed:
/^[1-9][0-9]{7}$/
But read the manual about the use of the starting and trailing shlashes.
Best regards
Joffm
you can use regular expression for that.
See all these examples:
manual.limesurvey.org/Using_regular_expressions
Maybe the expression of your desired phone format is already there.
So, in your survey you are looking for exactly eight digits?
Start with "0" is allowed?
Something like:
/^[0-9]{8}$/
Not allowed:
/^[1-9][0-9]{7}$/
But read the manual about the use of the starting and trailing shlashes.
Best regards
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 6 years 7 months ago by Joffm.
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12790
- Thank you received: 3940
6 years 7 months ago #157706
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Can i limit the answer to certain format or no. of characters?
Hi, wendyt,
of course there is a second solution.
Use a numerical input, set minimum value to "10000000", maximun value to "99999999".
Okay, only works if leading "0" is not allowed.
And about the slashes in my first post. In validation you have to use them.
Best regards
Joffm
of course there is a second solution.
Use a numerical input, set minimum value to "10000000", maximun value to "99999999".
Okay, only works if leading "0" is not allowed.
And about the slashes in my first post. In validation you have to use them.
Best regards
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
- wendyt
- Topic Author
- Offline
- New Member
Less
More
- Posts: 7
- Thank you received: 0
6 years 7 months ago #157713
by wendyt
Replied by wendyt on topic Can i limit the answer to certain format or no. of characters?
Thank you very much Joffm. This manual is very useful and not sure why I didn't find it earlier.
Appreciate much
Cheers,
Wendy
Appreciate much
Cheers,
Wendy
The topic has been locked.
- wendyt
- Topic Author
- Offline
- New Member
Less
More
- Posts: 7
- Thank you received: 0
6 years 7 months ago #157715
by wendyt
Replied by wendyt on topic Can i limit the answer to certain format or no. of characters?
Hello Joffm,
I read over the manual but didn't tell how to do if I'd like to apply the validation equation into a sub-question. For example if i have a multiple short text question and asking for their name and mobile number, how shall i enter the validation equation into the "Sub-question validation equation"?
Thanks again for your help and sorry i am not familiar to scripts.
Best regards,
Wendy
I read over the manual but didn't tell how to do if I'd like to apply the validation equation into a sub-question. For example if i have a multiple short text question and asking for their name and mobile number, how shall i enter the validation equation into the "Sub-question validation equation"?
Thanks again for your help and sorry i am not familiar to scripts.
Best regards,
Wendy
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12790
- Thank you received: 3940
6 years 7 months ago - 6 years 7 months ago #157728
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Can i limit the answer to certain format or no. of characters?
Hi, wendyt,
unfortunately you didn't mention this (multiple short text) in your first post.
There seems to be a bug in LS. Read www.limesurvey.org/forum/can-i-do-this-w...ext-regex-validation
So we have to find a different solution.
In "Sub-question validation equation:" enter: strlen(Q1_SQ003)==8 AND is_numeric(Q1_SQ003) AND substr(Q1_SQ003,0,1)!="0"
with Q1 = question code and SQ003 = subquestion code of the phone number.
I think you understand the meaning. The length of the string is 8 characters and it's numeric.
Add the blue part to avoid a leading "0".
In "Sub-question validation tip " you can enter something like "Please, enter exactly 8 digits in phone number"
Then you get (raw example screenshots)
Best regards
Joffm
unfortunately you didn't mention this (multiple short text) in your first post.
There seems to be a bug in LS. Read www.limesurvey.org/forum/can-i-do-this-w...ext-regex-validation
So we have to find a different solution.
In "Sub-question validation equation:" enter: strlen(Q1_SQ003)==8 AND is_numeric(Q1_SQ003) AND substr(Q1_SQ003,0,1)!="0"
with Q1 = question code and SQ003 = subquestion code of the phone number.
I think you understand the meaning. The length of the string is 8 characters and it's numeric.
Add the blue part to avoid a leading "0".
In "Sub-question validation tip " you can enter something like "Please, enter exactly 8 digits in phone number"
Then you get (raw example screenshots)
Best regards
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Attachments:
Last edit: 6 years 7 months ago by Joffm.
The following user(s) said Thank You: wendyt
The topic has been locked.
- wendyt
- Topic Author
- Offline
- New Member
Less
More
- Posts: 7
- Thank you received: 0
6 years 7 months ago #157750
by wendyt
Replied by wendyt on topic Can i limit the answer to certain format or no. of characters?
Appreciate much for your help Joffm. I need to set both short text and multiple short text for this validation and thanks so much for providing me the solution. Thanks again!
The topic has been locked.
- Mazi
- Offline
- Official LimeSurvey Partner
4 years 9 months ago #185522
by Mazi
You can use the character count feature documented at How to count the number of characters entered at a Limesurvey text question to show the user a warning like "You have entered X of 8 characters".
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
Replied by Mazi on topic Can i limit the answer to certain format or no. of characters?
wendyt wrote:
I'd like to ask for mobile phone in numerical input/short free text but would like to limit (or validate) the response to 8 characters. I can only do it by setting maximum characters of 8 but this won't help to warn answers with fewer than 8 characters (digits).Dear fellows,
You can use the character count feature documented at How to count the number of characters entered at a Limesurvey text question to show the user a warning like "You have entered X of 8 characters".
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The topic has been locked.