Answer only X or ##.##

Plus d'informations
il y a 9 mois 1 semaine #172146 par jimdavies
COM_KUNENA_MESSAGE_CREATED_NEW
Is it possible to force users to enter an answer as either an X or a two decimal number?



I had these settings to force an answer to be a two decimal number

Question validation equation: is_empty(self) OR regexMatch('/^[0-9]+(\.[0-9][0-9])$/',self)

Question validation tip: {if(is_empty(self) OR regexMatch('/^[0-9]+(\.[0-9][0-9])$/',self), "Enter number with two decimals points", "Enter number with TWO decimal points")}

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

LimeSurvey Partners
Plus d'informations
il y a 9 mois 1 semaine #172147 par Joffm
COM_KUNENA_MESSAGE_REPLIED_NEW
Hi,
though I think this is not the best way, ... up to you.

Just extend the regular expression.
A lot of examples here:
http://regexlib.com/DisplayPatterns.aspx?cattabindex=2&categoryId=3

E.g.
is_empty(self) OR regexMatch('/(^[0-9]+(\.[0-9][0-9])$)|(^X$)/',self)

Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Les utilisateur(s) suivant ont remercié: jimdavies

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

Plus d'informations
il y a 9 mois 1 semaine #172148 par jimdavies
COM_KUNENA_MESSAGE_REPLIED_NEW
Why is 100.00 not considered a valid value with this?

is_empty(self) OR regexMatch('/(^[0-9]+(\.[0-9][0-9])$)|(^X$)/',self)

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

Plus d'informations
il y a 9 mois 1 semaine #172149 par jelo
COM_KUNENA_MESSAGE_REPLIED_NEW
Could be a bug in LimeSurvey. There is a regex done in Javascript and in PHP. Somestimes there is a bug in one or both regex-routines.
You should prepare a survey with the nonworking part and attach it here.
What version of LimeSurvey was used?

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users

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

Plus d'informations
il y a 9 mois 1 semaine #172150 par jimdavies
COM_KUNENA_MESSAGE_REPLIED_NEW
Here is the survey. It's on our test environment so no worries if it's used. It's the third to the last question where I have the validation that doesn't accept 100.00
surveys-staging.peoplescout.com/691893?lang=en

I'm on Version 2.58.0+170104

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

Plus d'informations
il y a 9 mois 1 semaine - il y a 9 mois 1 semaine #172151 par Joffm
COM_KUNENA_MESSAGE_REPLIED_NEW
Check again.

Here is the result:
Wrong:


Correct:


regexMatch('/(^[0-9]+(\.[0-9][0-9])$)|(^X$)/',self)
As you know the "+" means: the expression before can be repeated 1 to x times and is a synonym for {1,}.
So you could try this or - I think you enter percentages up to 100 - {1,3}, which means 1 to 3 repeats.

Joffm

BTW:
If you work with 2.58 there is a far better way to do this.
Use the plugin "checkboxfortext".
Here you can have one or two checkboxes below the textinput field e.g. "NA" and "DK"


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Pièces jointes :
Last edit: il y a 9 mois 1 semaine by Joffm. Raison: wrong picture

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

Plus d'informations
il y a 9 mois 1 semaine #172153 par jimdavies
COM_KUNENA_MESSAGE_REPLIED_NEW
That's weird that 100.00 worked for you. I had another user try and he got the same result as me. But if you put in 100.01 it would take it

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

Plus d'informations
il y a 9 mois 1 semaine #172154 par Joffm
COM_KUNENA_MESSAGE_REPLIED_NEW
No, it's because you didn't say that you use 2.58.
Of course my example was in 3.13.2


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 9 mois 1 semaine #172155 par jimdavies
COM_KUNENA_MESSAGE_REPLIED_NEW
I mentioned the version up above. Is this a bug with the version I'm on?

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

Plus d'informations
il y a 9 mois 1 semaine - il y a 9 mois 1 semaine #172158 par Joffm
COM_KUNENA_MESSAGE_REPLIED_NEW
Hi, now I tested in Version 2.73.1+171220

is_empty(self) OR regexMatch('/(^[0-9]+(\.[0-9][0-9])$)|(^X$)/',self)


Wrong entries:



Correct entries:



I have not the least idea why there are problems in version 2.58

An here is a different approach:
array with some javascript. (entries are exclusive)


Joffm

Yes, you mentioned it.
But at that time I was already working on the example (not in the first post). I saw it after I submitted the post. ;)


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Pièces jointes :
Last edit: il y a 9 mois 1 semaine by Joffm.

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!