Answer only X or ##.##

Mehr
1 Woche 1 Tag her #172146 von jimdavies
jimdavies erstellte das Thema 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")}

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
1 Woche 1 Tag her #172147 von Joffm
Joffm antwortete auf das Thema: 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
Folgende Benutzer bedankten sich: jimdavies

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
1 Woche 1 Tag her #172148 von jimdavies
jimdavies antwortete auf das Thema: 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)

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
1 Woche 1 Tag her #172149 von jelo
jelo antwortete auf das Thema: 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?

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
1 Woche 1 Tag her #172150 von jimdavies
jimdavies antwortete auf das Thema: 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

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
1 Woche 1 Tag her - 1 Woche 1 Tag her #172151 von Joffm
Joffm antwortete auf das Thema: 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
Letzte Änderung: 1 Woche 1 Tag her von Joffm. Begründung: wrong picture

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
1 Woche 1 Tag her #172153 von jimdavies
jimdavies antwortete auf das Thema: 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

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
1 Woche 1 Tag her #172154 von Joffm
Joffm antwortete auf das Thema: 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

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
1 Woche 1 Tag her #172155 von jimdavies
jimdavies antwortete auf das Thema: Answer only X or ##.##
I mentioned the version up above. Is this a bug with the version I'm on?

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
1 Woche 1 Tag her - 1 Woche 1 Tag her #172158 von Joffm
Joffm antwortete auf das Thema: 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
Letzte Änderung: 1 Woche 1 Tag her von Joffm.

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Jetzt loslegen!

Melden Sie sich jetzt an, und erstellen Sie in wenigen Minuten Ihre erste Umfrage.

Account einrichten

Abonnieren Sie unseren Newsletter

Abonnieren Sie unseren Newsletter für alle Neuigkeiten rund um LimeSurvey
captcha