Check out the LimeSurvey source code on GitHub!

Expression Manager: Use Expressions in Validation field

More
5 years 4 weeks ago #73034 by Mazi
That makes sense!


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

More
5 years 4 weeks ago #73053 by Steve01
Hello,

I updated my "My little Test-Survey". The "Hide tip" option seems to work as mentioned. But I have the example donate question in the survey and it seems that the validation of the regex and/or EM expression seems to happen every time you answer a question even it you don't really enter anything in the donate question. So it is marked red but you even haven't answerd the question at all.

Have a look at the survey at
212.65.8.158/limesurveyEM/index.php?sid=61131&lang=en
If you for example enter a name the validation for the donate question will trigger and mark it red.

Mit freundlichen Grüßen/Best regards,

Stefan Gohlke
LimeSurvey Team

Please Log in to join the conversation.

More
5 years 4 weeks ago #73057 by Mazi
Talking about marking invalid answers: Can we have a light red background for text fields. Text in those fields is a little hard to read because of the strong red color.

Opinions?


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

More
5 years 4 weeks ago #73071 by TMSWhite

Mazi wrote: Talking about marking invalid answers: Can we have a light red background for text fields. Text in those fields is a little hard to read because of the strong red color.


Good idea. Can you recommend a specific CSS color?

Incidentally, I originally tried to do this by adding a style class, but I didn't see a reliable way to remove that class when the validation criteria pass (since there might be other classes attached to the question and I didn't want to mess them up).

Please Log in to join the conversation.

More
5 years 4 weeks ago #73073 by TMSWhite

vierundzwanzig wrote: I updated my "My little Test-Survey". The "Hide tip" option seems to work as mentioned. But I have the example donate question in the survey and it seems that the validation of the regex and/or EM expression seems to happen every time you answer a question even it you don't really enter anything in the donate question. So it is marked red but you even haven't answerd the question at all.


That's actually the intended behavior.
By default, if you have a regular expression validation, you can still leave the question blank. However, you added this em_validation_q criteria:
if(is_numeric(this), this > 50, substr(this, 1) > 50)

That criteria will fail if the question is blank, so EM is accurately flagging the question in red so that you know you have to answer it. To allow blank entries, you can adjust the em_validation_q to this:
if (is_empty(this),1,if(is_numeric(this), this > 50, substr(this, 1) > 50))

You may be asking a related question - is there a way to avoid flagging questions as red until the person navigates past that question. Eventually there may be a way to do that by using the qseq (question sequence) attribute, but I expect people may want that built in rather than needing to tailor the
em_validation_q equation. If that is a desirable feature, please add it to ideas.limesurvey.org so we can get some votes for/against it.

/Tom

Please Log in to join the conversation.

More
5 years 4 weeks ago #73113 by Steve01
Hello,

thank you for your explanation. I think I get why it doesn't work. I change the em_validation_q criteria using "is_empty(this)" and it now works fine.

From the programming logic it seems to be correct. I think you might want to validate a question if you "leave" the question or try to go to the next page/submit the survey. Is there any use case where you validate a question if you answer another question? I'm not sure about that.

Anyway, I added the idea to
ideas.limesurvey.org/ideatorrent/idea/368/
so other people can give feedback or even add other solutions.

Mit freundlichen Grüßen/Best regards,

Stefan Gohlke
LimeSurvey Team

Please Log in to join the conversation.

More
5 years 4 weeks ago - 5 years 4 weeks ago #73127 by Mazi

TMSWhite wrote:

Mazi wrote: Talking about marking invalid answers: Can we have a light red background for text fields. Text in those fields is a little hard to read because of the strong red color.


Good idea. Can you recommend a specific CSS color?

Hmm... maybe something like "#F75D59" -> Indian Red1 at www.computerhope.com/htmcolor.htm

Example
SOME BOLD TEXT WITH A NICE RED COLOR


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"
Last Edit: 5 years 4 weeks ago by Mazi.

Please Log in to join the conversation.

More
5 years 4 weeks ago #73163 by Fred01

if, for example, the community says we should never show the regular expression or equation-based validation equations, instead requiring people to enter something into "help" to explain the validation in human-readable terms.


Just my two cents, but I can't think of a single instance when you would want survey respondents to see a help message containing a regular expression. It's incomprehensible. And I don't think we'd want to use the "hide tip" box to hide ALL tips on the question. Unfortunately, maybe there also needs to be a Validation Help text field next to the regex validation field?

A lot of end users are going to be pretty confused about all this :huh:

Please Log in to join the conversation.

More
5 years 3 weeks ago #73164 by TMSWhite
Fred-

I think you're in the majority on this - I opened a bug ticket.

/Tom
The following user(s) said Thank You: Fred01

Please Log in to join the conversation.

More
5 years 3 weeks ago #73165 by Fred01
I installed RC3 and the validation messages are appearing now. Thanks.

One minor thing is that the messages are using different CSS class ids. Using the example of the multi-numeric question where the amounts must not exceed 100:

When I run the question in 1.93 it shows both messages, but using different styles

<span class="questionhelp" id="442_vmsg">The sum must equal 100</span>
<div class="survey-question-answer"><p class="tip">Only numbers may be entered in these fields

In v. 1.91 both messages use the survey-question-answer style

Please Log in to join the conversation.

More
5 years 3 weeks ago #73166 by TMSWhite
Fred-

The team has started a discussion about this. We need more granular styles for the various types of help/tip and validation messages. Once we have a good sense of the direction we can support/recommend, we'll probably solicit the community for feedback.

/Tom

Please Log in to join the conversation.

More
5 years 3 weeks ago #73167 by Fred01
Ok great. I figured there might be some other instances like this as well. Looking forward to updating my template... :)

Fred

Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form