Can i limit the answer to certain format or no. of characters?

Plus d'informations
il y a 2 ans 1 mois #157690 par 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.

Connexion ou Créer un compte pour participer à la conversation.

LimeSurvey Partners
Plus d'informations
il y a 2 ans 1 mois - il y a 2 ans 1 mois #157697 par Joffm
Hi, wendyt,

you can use regular expression for that.
See all these examples:
https://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
Dernière édition: il y a 2 ans 1 mois par Joffm.
Les utilisateur(s) suivant ont remercié: LouisGac

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 2 ans 1 mois #157706 par Joffm
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


Volunteers are not paid.
Not because they are worthless, but because they are priceless

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 2 ans 1 mois #157713 par wendyt
Thank you very much Joffm. This manual is very useful and not sure why I didn't find it earlier.

Appreciate much :)

Cheers,
Wendy

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 2 ans 1 mois #157715 par wendyt
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

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 2 ans 1 mois - il y a 2 ans 1 mois #157728 par Joffm
Hi, wendyt,
unfortunately you didn't mention this (multiple short text) in your first post.

There seems to be a bug in LS. Read https://www.limesurvey.org/forum/can-i-do-this-with-limesurvey/109810-multiple-short-text-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
Pièces jointes :
Dernière édition: il y a 2 ans 1 mois par Joffm.
Les utilisateur(s) suivant ont remercié: wendyt

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 2 ans 4 semaines #157750 par wendyt
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!

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 3 mois 1 semaine #185522 par Mazi

wendyt écrit:

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).


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
Contact: marcel.minke(at)survey-consulting.com
Want to use your survey offline -> www.offlinesurveys.com

Connexion ou Créer un compte pour participer à la conversation.

Commencez dès maintenant !

Créez simplement un compte et commencez à utiliser LimeSurvey dès aujourd'hui.

Inscrivez-vous maintenant

Inscrivez-vous à notre Newsletter!