Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Search Results (Searched for: validation)

  • AntPIC
  • AntPIC's Avatar
31 Aug 2023 13:04
Thank you very much Joffm.
with this code now work

(F1.NAOK<1 OR (regexMatch("/^[A-DF-HJ-NP-TV-Z]{6}[0-9]{2}[A-EHLMPRST]([04][1-9])|([1-25-6][0-9])|([37][01])[A-Z][0-9]{3}[A-Z]$/", strtoupper(F1a_SQ001_SQ003.NAOK)) AND regexMatch('/^.+?@.+?\..+$/', F1a_SQ001_SQ004.NAOK) AND strlen(F1a_SQ001_SQ006.NAOK)==2)) AND
(F1.NAOK<2 OR (regexMatch("/^[A-DF-HJ-NP-TV-Z]{6}[0-9]{2}[A-EHLMPRST]([04][1-9])|([1-25-6][0-9])|([37][01])[A-Z][0-9]{3}[A-Z]$/", strtoupper(F1a_SQ002_SQ003.NAOK)) AND regexMatch('/^.+?@.+?\..+$/', F1a_SQ002_SQ004.NAOK) AND strlen(F1a_SQ002_SQ006.NAOK)==2)) AND
...

but i didn't understand how to do this?
3. Check for hidden HTML, like <br>. Insert it into the question text with surrounding curly brackets and you will see.
With this changed the syntax is correct.

I know I have to put drop-down. I asked before, but as I told you i don't know how programming language. Is there a simple way to do drop-down in the array text? Or for check the insert answer?

Thanks a lot indeed
  • Joffm
  • Joffm's Avatar
31 Aug 2023 11:32 - 31 Aug 2023 11:43
Hi,
is this exactly the code you entered?

1. It is NAOK, not Naok. These things are case sensitive.
2. AND ('/^.+?@.+?\..+$/', F1a_SQ001_SQ004.NAOK)   regexMatch is missing
3. Check for hidden HTML, like <br>. Insert it into the question text with surrounding curly brackets and you will see.
With this changed the syntax is correct.

And add ".NAOK" to the "strlen " term.

Now I do not see an issue with this (I shortened the fiscal regex for testing)
(F1.NAOK<1 OR (regexMatch("/^[A-DF-HJ-NP-TV-Z]{6}$/", strtoupper(F1a_Y001_X003.NAOK)) AND regexMatch('/^.+?@.+?\..+$/', F1a_Y001_X004.NAOK) AND strlen(F1a_Y001_X006.NAOK)==2)) AND
(F1.NAOK<2 OR (regexMatch("/^[A-DF-HJ-NP-TV-Z]{6}$/", strtoupper(F1a_Y002_X003.NAOK)) AND regexMatch('/^.+?@.+?\..+$/', F1a_Y002_X004.NAOK) AND strlen(F1a_Y002_X006.NAOK)==2)) AND
(F1.NAOK<3 OR (regexMatch("/^[A-DF-HJ-NP-TV-Z]{6}$/", strtoupper(F1a_Y003_X003.NAOK)) AND regexMatch('/^.+?@.+?\..+$/', F1a_Y003_X004.NAOK) AND strlen(F1a_Y003_X006.NAOK)==2)) AND (F1.NAOK<4 OR (regexMatch("/^[A-DF-HJ-NP-TV-Z]{6}$/", strtoupper(F1a_Y004_X003.NAOK)) AND regexMatch('/^.+?@.+?\..+$/', F1a_Y004_X004.NAOK) AND strlen(F1a_Y004_X006.NAOK)==2))

...





Very probably "role" has a limited number of possible answer options.
So I advice to use drop-downs here and also for the last "Si/No" question.
Though you check for "strlen==2" you still can enter "xx", "1a", or whatever.
If you keep the role as a free text question, you will have a lot to recode in your analysis.

Could be like this
 
 
You only have to check for "not empty".

Joffm
  • AntPIC
  • AntPIC's Avatar
31 Aug 2023 09:17
whatever I enter it asks me to always validate all 10 operators, even if 4 appear on the basis of the previous question. How can I fix?
  • AntPIC
  • AntPIC's Avatar
30 Aug 2023 23:51
Thanks! But it does not work..
i put this code

F1.Naok<1
OR
(regexMatch("/^[A-DF-HJ-NP-TV-Z]{6}[0-9]{2}[A-EHLMPRST]([04][1-9])|([1-25-6][0-9])|([37][01])[A-Z][0-9]{3}[A-Z]$/", strtoupper(F1a_SQ001_SQ003.NAOK)) AND ('/^.+?@.+?\..+$/', F1a_SQ001_SQ004.NAOK) AND strlen(F1a_SQ001_SQ006)==2) AND
F1.Naok<2 OR
(regexMatch("/^[A-DF-HJ-NP-TV-Z]{6}[0-9]{2}[A-EHLMPRST]([04][1-9])|([1-25-6][0-9])|([37][01])[A-Z][0-9]{3}[A-Z]$/", strtoupper(F1a_SQ002_SQ003.NAOK)) AND regexMatch('/^.+?@.+?\..+$/', F1a_SQ002_SQ004.NAOK) AND strlen(F1a_SQ002_SQ006)==2) AND
F1.Naok<3 OR
(regexMatch("/^[A-DF-HJ-NP-TV-Z]{6}[0-9]{2}[A-EHLMPRST]([04][1-9])|([1-25-6][0-9])|([37][01])[A-Z][0-9]{3}[A-Z]$/", strtoupper(F1a_SQ003_SQ003.NAOK)) AND regexMatch('/^.+?@.+?\..+$/', F1a_SQ003_SQ004.NAOK) AND strlen(F1a_SQ003_SQ006) ==2) AND
...

I don't know what is the problem
  • tpartner
  • tpartner's Avatar
30 Aug 2023 21:23
Replied by tpartner on topic multiple sub-question validation in text array
Put in new conditions to bypass yours depending on the value of the "operators" question.
Code:
    operators < 1
    OR
    (
        regexMatch("/^[A-DF-HJ-NP-TV-Z]{6}[0-9]{2}[A-EHLMPRST]([04][1-9])|([1-25-6][0-9])|([37][01])[A-Z][0-9]{3}[A-Z]$/", strtoupper(F1a_SQ001_SQ003.NAOK)) 
        AND 
        regexMatch('/^.+?@.+?\..+$/', F1a_SQ001_SQ004.NAOK) 
        AND 
        strlen(F1a_SQ001_SQ006)==2
    )
AND
    operators < 2
    OR
    (
        regexMatch("/^[A-DF-HJ-NP-TV-Z]{6}[0-9]{2}[A-EHLMPRST]([04][1-9])|([1-25-6][0-9])|([37][01])[A-Z][0-9]{3}[A-Z]$/", strtoupper(F1a_SQ002_SQ003.NAOK)) 
        AND 
        regexMatch('/^.+?@.+?\..+$/', F1a_SQ002_SQ004.NAOK) 
        AND 
        strlen(F1a_SQ002_SQ006)==2
    )
AND
...
  • AntPIC
  • AntPIC's Avatar
30 Aug 2023 20:50
LimeSurvey Cloud
Versione 3.28.66

==================I have a text array with 6 columns and 10 rows. The rows open according to the number of operators indicated in the previous question. I tried to insert the validation of the sub-questions by email tax code and last column field max 2 characters. the controls work but it tells me that I must always fill in all ten operators. For example, if in the previous question I indicate 4 operators and correctly fill in the relative fields in the array, however, it returns an error and lets me continue only if I fill in all 10 operators. I insert the formula and the screenshot below

regexMatch("/^[A-DF-HJ-NP-TV-Z]{6}[0-9]{2}[A-EHLMPRST]([04][1-9])|([1-25-6][0-9])|([37][01])[A-Z][0-9]{3}[A-Z]$/", strtoupper(F1a_SQ001_SQ003.NAOK)) AND ('/^.+?@.+?\..+$/', F1a_SQ001_SQ004.NAOK) AND strlen(F1a_SQ001_SQ006)==2 AND
regexMatch("/^[A-DF-HJ-NP-TV-Z]{6}[0-9]{2}[A-EHLMPRST]([04][1-9])|([1-25-6][0-9])|([37][01])[A-Z][0-9]{3}[A-Z]$/", strtoupper(F1a_SQ002_SQ003.NAOK)) AND regexMatch('/^.+?@.+?\..+$/', F1a_SQ002_SQ004.NAOK) AND strlen(F1a_SQ002_SQ006)==2  AND
regexMatch("/^[A-DF-HJ-NP-TV-Z]{6}[0-9]{2}[A-EHLMPRST]([04][1-9])|([1-25-6][0-9])|([37][01])[A-Z][0-9]{3}[A-Z]$/", strtoupper(F1a_SQ003_SQ003.NAOK)) AND regexMatch('/^.+?@.+?\..+$/', F1a_SQ003_SQ004.NAOK) AND strlen(F1a_SQ003_SQ006) ==2 AND
regexMatch("/^[A-DF-HJ-NP-TV-Z]{6}[0-9]{2}[A-EHLMPRST]([04][1-9])|([1-25-6][0-9])|([37][01])[A-Z][0-9]{3}[A-Z]$/", strtoupper(F1a_SQ004_SQ003.NAOK)) AND regexMatch('/^.+?@.+?\..+$/', F1a_SQ004_SQ004.NAOK) AND strlen(F1a_SQ004_SQ006)==2 AND
regexMatch("/^[A-DF-HJ-NP-TV-Z]{6}[0-9]{2}[A-EHLMPRST]([04][1-9])|([1-25-6][0-9])|([37][01])[A-Z][0-9]{3}[A-Z]$/", strtoupper(F1a_SQ005_SQ003.NAOK)) AND regexMatch('/^.+?@.+?\..+$/', F1a_SQ005_SQ004.NAOK) AND strlen(F1a_SQ005_SQ006)==2 AND
regexMatch("/^[A-DF-HJ-NP-TV-Z]{6}[0-9]{2}[A-EHLMPRST]([04][1-9])|([1-25-6][0-9])|([37][01])[A-Z][0-9]{3}[A-Z]$/", strtoupper(F1a_SQ006_SQ003.NAOK)) AND regexMatch('/^.+?@.+?\..+$/', F1a_SQ006_SQ004.NAOK) AND strlen(F1a_SQ006_SQ006)==2 AND
regexMatch("/^[A-DF-HJ-NP-TV-Z]{6}[0-9]{2}[A-EHLMPRST]([04][1-9])|([1-25-6][0-9])|([37][01])[A-Z][0-9]{3}[A-Z]$/", strtoupper(F1a_SQ007_SQ003.NAOK)) AND regexMatch('/^.+?@.+?\..+$/', F1a_SQ007_SQ004.NAOK) AND strlen(F1a_SQ007_SQ006)==2 AND
regexMatch("/^[A-DF-HJ-NP-TV-Z]{6}[0-9]{2}[A-EHLMPRST]([04][1-9])|([1-25-6][0-9])|([37][01])[A-Z][0-9]{3}[A-Z]$/", strtoupper(F1a_SQ008_SQ003.NAOK)) AND regexMatch('/^.+?@.+?\..+$/', F1a_SQ008_SQ004.NAOK) AND strlen(F1a_SQ008_SQ006)==2 AND
regexMatch("/^[A-DF-HJ-NP-TV-Z]{6}[0-9]{2}[A-EHLMPRST]([04][1-9])|([1-25-6][0-9])|([37][01])[A-Z][0-9]{3}[A-Z]$/", strtoupper(F1a_SQ009_SQ003.NAOK)) AND regexMatch('/^.+?@.+?\..+$/', F1a_SQ009_SQ004.NAOK) AND strlen(F1a_SQ009_SQ006)==2 AND
regexMatch("/^[A-DF-HJ-NP-TV-Z]{6}[0-9]{2}[A-EHLMPRST]([04][1-9])|([1-25-6][0-9])|([37][01])[A-Z][0-9]{3}[A-Z]$/", strtoupper(F1a_SQ010_SQ003.NAOK)) AND regexMatch('/^.+?@.+?\..+$/', F1a_SQ010_SQ004.NAOK) AND strlen(F1a_SQ010_SQ006)==2

 
  • Joffm
  • Joffm's Avatar
30 Aug 2023 12:45
Replied by Joffm on topic See statistic about assessment
Hi,
in my first answer I wrote - and it is still true

assessment values are not stored.
These assessment feature is only to display something to the respondent.

To store this, you have to use ExpressionScript to calculate the score, to create the message, and so on.
As I showed here

Or better - to store the value - create a question if type equation with this function (you may call it "score")
{10*count(that.Q00001.NAOK,that.Q00002.NAOK,that.Q00003.NAOK,that.Q00004.NAOK,that.Q00005.NAOK)}

Or, if you only want to store the verbatim result in a variable of the database.
{if(10*count(that.Q00001.NAOK,that.Q00002.NAOK,that.Q00003.NAOK,that.Q00004.NAOK,that.Q00005.NAOK)>49,"Your text","Your other text")}

There are many sample survey in the manual:
Download, import them and study them to learn the basics about ExpressionScript
[url] manual.limesurvey.org/ExpressionScript_sample_surveys/en [/url]

And also again: Please, read this part of the manual
 

Create a small test survey, enter some equations .
Then activate it, enter some data and have a look at the answer table,

Joffm

By the way:
You should read the part about "question types" as well, to understand the "array filter" and "validation equation"
 
  • Joffm
  • Joffm's Avatar
29 Aug 2023 17:42 - 29 Aug 2023 17:45
Replied by Joffm on topic See statistic about assessment
Please, please, read the manual!

In all your questions there is
  • an array exclusion filter though there is no such question before - and in the filter there seem to be subquestion codes
  • an array filter though there is no such question before - and in the filter there seem to be subquestion codes
  • a validation tip but no validation equation.
I have not the least idea what you want tp achieve, because this is - sorry - nonsense.

Why is the question text in the first question "1 + 1"?
And in the fourth question "1 + 1" and "2 + 2"?

You use assessment rules. But in my opinion these are not usable in multple questions.
What you do, you only count the selected items, multiplied by 10.

Since there is ExpressionScript nobody uses this outdated assessment rules.
By the way: What you di now, you can di easier by inserting this in the endpage

{if(10*count(that.Q00001.NAOK,that.Q00002.NAOK,that.Q00003.NAOK,that.Q00004.NAOK,that.Q00005.NAOK)>49,"Your text","Your other text")}

Or better - to store the value - create a question if type equation with this function (you may call it "score")
{10*count(that.Q00001.NAOK,that.Q00002.NAOK,that.Q00003.NAOK,that.Q00004.NAOK,that.Q00005.NAOK)}

and in the endpage you display

You achieved {score} points. {if(score>50,"This is fantastic","This is not too bad")}

Joffm
  • Joffm
  • Joffm's Avatar
25 Aug 2023 00:24
Replied by Joffm on topic Array (Numbers) Subquestion validation
Hi,

Why didn't you answer the initial questions about your version, etc.?

You have to use the correct QCODES to access the cells.
As described here
[url] manual.limesurvey.org/ExpressionScript_-...code_variable_naming [/url]

You have an array(numbers). So there are two axes of subquestions
Meaning:
Total of Spotify: Q1_SQ002_SQ001
Total of Facebook: Q1_SQ003_SQ001
Subtotal1 of Spotify: Q1_SQ002_SQ008
and so on.

I always advice to use different codes for y-axis ("Y001", "Y002",...) and x-axis ("X001", "X002",...) less confusion

Furthermore your function is wrong.
Read again here
[url] manual.limesurvey.org/ExpressionScript_-...mplemented_functions [/url]

And at last: it is not a subquestion validation.
You have to use question validation and insert all rows.

Joffm
  • luis.d.gongora
  • luis.d.gongora's Avatar
24 Aug 2023 19:23
Array (Numbers) Subquestion validation was created by luis.d.gongora
Please help us help you and fill where relevant:
Your LimeSurvey version: [see right hand bottom of your LimeSurvey admin screen]
Own server or LimeSurvey hosting:
Survey theme/template:
==================
How can I validate that the sum of subtotals are less or equal to the Total in an Array (Numerics)?

I have a table with 2 rows and 3 columns:
 

So what's the best option to alert to a user that the sum of Subtotal1 + Subtotal2 is greather than the Total.
I tried writing a formula but it doesn't recognize the variables, so I don't know where to start looking:
 
 
 
  • DenisChenu
  • DenisChenu's Avatar
21 Aug 2023 10:15
Replied by DenisChenu on topic Affichage écrit après validation réponse
Questionnaire en mode question par question ou groupe par groupe ?

Si c'est question par question : tu peux utiliser {if(!is_empty(Q00),"La bonne réponse est …")} si le code de la question est Q00 (par exemple)
Si c'est en groupe par groupe !is_empty(Q00) comme condition sur une question d etype affichage de texte.

Attention : la personne pourra modifier sa réponses.
 
  • CDCCCF
  • CDCCCF's Avatar
04 Aug 2023 14:25
Bonjour,

Je souhaiterais qu'une fois qu'une réponse à une question est validée, que la bonne réponse s'affiche en texte avec une explication sur la même page. Est-ce possible ? 
Pour le moment j'ai inscrit la question, les gens valident une réponse, passent à la page suivante dans laquelle y est inscrit uniquement du texte avec la bonne réponse. 

je vous remercie et vous souhaite une belle journée,


:)
  • mapage
  • mapage's Avatar
01 Aug 2023 07:28 - 13 Nov 2023 17:33
Great for the translation.. even if between js in the code of the question, tips in the validation code, it can be a certain burden to maintain..
Regarding the js, the issue might have been linked to the <option value=""> which was "" instead of "0", but in the end, I've removed the mandatory and only setup the validation test you gave me.
All fine at the moment from my side now :) 
Again thank you for your help.
Code:
<script type="text/javascript" charset="utf-8">
    $(document).on('ready pjax:scriptcomplete',function(){
        var thisQuestion = $('#question{QID}');  
        // Insert selects
        $('.answer-item.answer_cell_TP01a', thisQuestion).addClass('with-select').append('<select class="inserted-select form-control list-question-select">\
                                                    <option value="">Type 1</option>\
                                                    <option value="1">Type 2</option>\
                                                    <option value="2">Type 3</option>\
                                                </select>');
        // Listeners
        $('.inserted-select', thisQuestion).on('change', function(i) {
            if($(this).val() != '') {
                $(this).closest('.answer-item').find('input:text').val($.trim($('option:selected', this).text())).trigger('change');
            }
            else {
                $(this).closest('.answer-item').find('input:text').val('').trigger('change');
            }
        });                    
        // Returning to page
        $('.with-select input:text', thisQuestion).each(function(i) {
            var thisCell = $(this).closest('.answer-item');
            var inputText = $.trim($(this).val());
            var selectval = $('select.inserted-select option', thisCell).filter(function () { return $(this).html() == inputText; }).val();
            $('select.inserted-select', thisCell).val(selectval);
        });    
        // Clean-up styles
        $('select.inserted-select', thisQuestion).css({
            'max-width': '100%'
        });
        $('.with-select input:text', thisQuestion).css({
            'position': 'absolute',
            'left': '-9999em'
        });
    });
</script>
  • mapage
  • mapage's Avatar
30 Jul 2023 15:00
I'll stop keeping you busy : validation step is 90% covering the need + setting the question not mandatory it works around the issue I had.
For this the validation at the right place as explained previously is very good.
Note that validation only "tips" is very good if you do not need multilingual help as it's a global solution for the question.
PS: lss was the one you've used to say I did wrong (again ).
  • Joffm
  • Joffm's Avatar
28 Jul 2023 14:16

Where shall I insert this validation ? In the condition area or in the Regex one ?

Neither nor.
Validations - except regex - are done in "Logic / question validation equation"
as you read in the manual in each "question type"
[url] manual.limesurvey.org/Question_type_-_Ar...28em_validation_q.29 [/url]

Joffm
Displaying 121 - 135 out of 181 results.

Lime-years ahead

Online-surveys for every purse and purpose