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
  • FranzGerbig's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
8 years 7 months ago - 8 years 7 months ago #124217 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?"
Y-scalesubq1a)
subq2b)
X-scalesubq1City (wanted: text)
subq2inhabitants (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
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 7 months ago #124226 by tpartner
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:
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
  • FranzGerbig's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
8 years 7 months ago #124227 by FranzGerbig
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

using LS 3.13.2+180709
The topic has been locked.
  • FranzGerbig
  • FranzGerbig's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
8 years 7 months ago #124236 by FranzGerbig
- inputmask.numeric.extensions.js
- jquery.inputmask.js

these filenames are "not allowed to be uploaded"!

using LS 3.13.2+180709
The topic has been locked.
More
8 years 7 months ago #124240 by jelo
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
  • FranzGerbig's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
8 years 7 months ago #124241 by FranzGerbig
via FTP? Sorry, what do mean?

using LS 3.13.2+180709
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 7 months ago - 8 years 7 months ago #124244 by tpartner

these filenames are "not allowed to be uploaded

I think with the default config settings, you should be able to upload .js files. What version of LimeSurvey are you using?

If I got it right, there was a setting which can be set in config files to weaking the filetypes filter for broader uploads.

Yes, this is the default config setting in 2.05 and 2.06:
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
  • FranzGerbig's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
8 years 7 months ago #124245 by FranzGerbig
I'm using 2.06 150815 and the 1st (inputmask.js) was uploaded with success ...
I guess I will try the export-import way

using LS 3.13.2+180709
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 7 months ago - 8 years 7 months ago #124264 by tpartner
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.

Lime-years ahead

Online-surveys for every purse and purpose