- Posts: 61
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
validate just 1 sub-question (X-scale) of array (text) as numerical input?
- FranzGerbig
- Topic Author
- Offline
- Senior Member
Less
More
8 years 7 months ago - 8 years 7 months ago #124217
by FranzGerbig
using LS 3.13.2+180709
validate just 1 sub-question (X-scale) of array (text) as numerical input? was created by FranzGerbig
Hi,
(sorry for the unwanted posting in [url=https://www.limesurvey.org/en/forum/installation-a-update-issues/101204-how-to-validate-just-1-sub-question-x-scale-array-texts-as-numerical-input#124215[/url]!)
a somewhat tricky issue:
How to validate one sub-question (X-scale) of an array (texts) as numerical input subq (best with a range of 1-999 in each cell of X-subq2)?
e.g. "What are cities nearby and how many inhabitants do you think they have each?"
Thanks in advance for any tips
bilo
(sorry for the unwanted posting in [url=https://www.limesurvey.org/en/forum/installation-a-update-issues/101204-how-to-validate-just-1-sub-question-x-scale-array-texts-as-numerical-input#124215[/url]!)
a somewhat tricky issue:
How to validate one sub-question (X-scale) of an array (texts) as numerical input subq (best with a range of 1-999 in each cell of X-subq2)?
e.g. "What are cities nearby and how many inhabitants do you think they have each?"
Y-scale | subq1 | a) |
subq2 | b) | |
X-scale | subq1 | City (wanted: text) |
subq2 | inhabitants (wanted: numbers) |
Thanks in advance for any tips
bilo
using LS 3.13.2+180709
Last edit: 8 years 7 months ago by FranzGerbig.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10103
- Thank you received: 3591
8 years 7 months ago #124226
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic validate just 1 sub-question (X-scale) of array (text) as numerical input?
I would place a mask on those inputs restricting to integers. I have recently used
RobinHerbots jquery.inputmask
with good results.
1) Set up your survey to use JavaScript .
2) Download the zip file and place these files in your template directory:
- inputmask.js
- inputmask.numeric.extensions.js
- jquery.inputmask.js
3) Add this to startpage.pstpl after the {TEMPLATEJS} tag:
4) Add a script like something like this to the source of the array.
1) Set up your survey to use JavaScript .
2) Download the zip file and place these files in your template directory:
- inputmask.js
- inputmask.numeric.extensions.js
- jquery.inputmask.js
3) Add this to startpage.pstpl after the {TEMPLATEJS} tag:
Code:
<script type="text/javascript" src="{TEMPLATEURL}inputmask.js"></script> <script type="text/javascript" src="{TEMPLATEURL}jquery.inputmask.js"></script> <script type="text/javascript" src="{TEMPLATEURL}inputmask.numeric.extensions.js"></script>
4) Add a script like something like this to the source of the array.
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify this question var thisQuestion = $('#question{QID}'); // Assign column-specific classes $('table.subquestions-list tr', thisQuestion).each(function(i){ $('> *', this).each(function(i){ $(this).addClass('column-'+i+''); }); }); // Place an "Integer" mask on the column-2 inputs $('table.subquestions-list .column-2 input[type="text"]', thisQuestion).inputmask('integer', { allowMinus: false, allowPlus: false, 'max': 999, 'min': 0, autoUnmask: true }); }); </script>
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: FranzGerbig
The topic has been locked.
- FranzGerbig
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 61
- Thank you received: 0
8 years 7 months ago #124227
by FranzGerbig
using LS 3.13.2+180709
Replied by FranzGerbig on topic validate just 1 sub-question (X-scale) of array (text) as numerical input?
My desperate trial: put the following into sub-question validation equation
"
EinzugsTest_SQ001_SQ002 >= 1 and EinzugsTest_SQ001_SQ002 <= 999, EinzugsTest_SQ002_SQ002 >= 1 and EinzugsTest_SQ002_SQ002 <= 999, EinzugsTest_SQ003_SQ002 >= 1 and EinzugsTest_SQ003_SQ002 <= 999
"
Survey logic is ok, but
- somehow, "((sum( ! " and ")) == 0))" are added to the equation (see attached), and
- if I enter a number higher than 999 the error seems to appear lacking some systematic pattern.
Thanks in advance for any tips
bilo
"
EinzugsTest_SQ001_SQ002 >= 1 and EinzugsTest_SQ001_SQ002 <= 999, EinzugsTest_SQ002_SQ002 >= 1 and EinzugsTest_SQ002_SQ002 <= 999, EinzugsTest_SQ003_SQ002 >= 1 and EinzugsTest_SQ003_SQ002 <= 999
"
Survey logic is ok, but
- somehow, "((sum( ! " and ")) == 0))" are added to the equation (see attached), and
- if I enter a number higher than 999 the error seems to appear lacking some systematic pattern.
Thanks in advance for any tips
bilo
using LS 3.13.2+180709
Attachments:
The topic has been locked.
- FranzGerbig
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 61
- Thank you received: 0
8 years 7 months ago #124236
by FranzGerbig
using LS 3.13.2+180709
Replied by FranzGerbig on topic validate just 1 sub-question (X-scale) of array (text) as numerical input?
- inputmask.numeric.extensions.js
- jquery.inputmask.js
these filenames are "not allowed to be uploaded"!
- jquery.inputmask.js
these filenames are "not allowed to be uploaded"!
using LS 3.13.2+180709
The topic has been locked.
- jelo
- Offline
- Platinum Member
Less
More
- Posts: 5033
- Thank you received: 1257
8 years 7 months ago #124240
by jelo
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
Replied by jelo on topic validate just 1 sub-question (X-scale) of array (text) as numerical input?
You have to upload them via FTP. The Theme upload is a bit too secure in terms of adding files. I would like to see a generic upload routine out of the box. If I got it right, there was a setting which can be set in config files to weaking the filetypes filter for broader uploads.
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
- FranzGerbig
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 61
- Thank you received: 0
8 years 7 months ago #124241
by FranzGerbig
using LS 3.13.2+180709
Replied by FranzGerbig on topic validate just 1 sub-question (X-scale) of array (text) as numerical input?
via FTP? Sorry, what do mean?
using LS 3.13.2+180709
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10103
- Thank you received: 3591
8 years 7 months ago - 8 years 7 months ago #124244
by tpartner
An alternative to FTP may be to export the template, add the files to the downloaded template zip file and then re-import the template.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic validate just 1 sub-question (X-scale) of array (text) as numerical input?
I think with the default config settings, you should be able to upload .js files. What version of LimeSurvey are you using?these filenames are "not allowed to be uploaded
Yes, this is the default config setting in 2.05 and 2.06:If I got it right, there was a setting which can be set in config files to weaking the filetypes filter for broader uploads.
Code:
$config['allowedtemplateuploads'] = 'gif,ico,jpg,png,css,js,map,json,eot,svg,ttf,woff,txt,md'; // File types allowed to be uploaded in the templates section.
An alternative to FTP may be to export the template, add the files to the downloaded template zip file and then re-import the template.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 8 years 7 months ago by tpartner.
The following user(s) said Thank You: FranzGerbig
The topic has been locked.
- FranzGerbig
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 61
- Thank you received: 0
8 years 7 months ago #124245
by FranzGerbig
using LS 3.13.2+180709
Replied by FranzGerbig on topic validate just 1 sub-question (X-scale) of array (text) as numerical input?
I'm using 2.06 150815 and the 1st (inputmask.js) was uploaded with success ...
I guess I will try the export-import way
I guess I will try the export-import way
using LS 3.13.2+180709
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10103
- Thank you received: 3591
8 years 7 months ago - 8 years 7 months ago #124264
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic validate just 1 sub-question (X-scale) of array (text) as numerical input?
It's very odd that you can [strike]import[/strike] upload one .js file but not others.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 8 years 7 months ago by tpartner.
The topic has been locked.