Answer only X or ##.##

Plus d'informations
il y a 1 semaine 6 jours #172146 par jimdavies
jimdavies a créé le sujet : Answer only X or ##.##
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.

Plus d'informations
il y a 1 semaine 6 jours #172147 par Joffm
Joffm a répondu au sujet : Answer only X or ##.##
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 1 semaine 6 jours #172148 par jimdavies
jimdavies a répondu au sujet : Answer only X or ##.##
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 1 semaine 6 jours #172149 par jelo
jelo a répondu au sujet : Answer only X or ##.##
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?

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

Plus d'informations
il y a 1 semaine 6 jours #172150 par jimdavies
jimdavies a répondu au sujet : Answer only X or ##.##
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 1 semaine 6 jours - il y a 1 semaine 6 jours #172151 par Joffm
Joffm a répondu au sujet : Answer only X or ##.##
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 :
Dernière édition: il y a 1 semaine 6 jours par Joffm. Raison: wrong picture

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

Plus d'informations
il y a 1 semaine 6 jours #172153 par jimdavies
jimdavies a répondu au sujet : Answer only X or ##.##
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 1 semaine 6 jours #172154 par Joffm
Joffm a répondu au sujet : Answer only X or ##.##
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 1 semaine 6 jours #172155 par jimdavies
jimdavies a répondu au sujet : Answer only X or ##.##
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 1 semaine 5 jours - il y a 1 semaine 5 jours #172158 par Joffm
Joffm a répondu au sujet : Answer only X or ##.##
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 :
Dernière édition: il y a 1 semaine 5 jours par 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!