Welcome to the LimeSurvey Community Forum

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

Could I limit the short free text answer is between 5-12?

  • LisaTW
  • LisaTW's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
2 years 10 months ago #216306 by LisaTW
Hi there,
I'm trying to design a short free text question, only numbers can be entered in this answer box. Could I limit the answer is between 5-12?
Looking for your help!

Lisa
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 10 months ago #216307 by holch
So if only numbers can be entered, why not using a "numerical input" question type? It already is limited to numbers only and there is the option to set a minimum and a maximum:
manual.limesurvey.org/Question_type_-_Numerical_input

A short free text you could validate ( manual.limesurvey.org/Question_type_-_Sh...28preg_validation.29 ), but why would you use a short free text question for numbers, if the "numerical input" questiontype already offers everything you need out of the box (only numbers may be inserted and you have minimum/maximum settings already out of the box)?

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
  • LisaTW
  • LisaTW's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
2 years 10 months ago #216337 by LisaTW
Hi Holch,
Thank you for your suggestion.
For this short free text question: What is your postal code? (e.g. 1234AB),
could I limit the correct answer format is four numbers and two letters?
Looking for your help!

Lisa
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 10 months ago - 2 years 10 months ago #216341 by Joffm
Hi,
this you can  do by validating the "short text question" with Regular Expression./^[1-9][0-9]{3}[A-Z]{2}$/ 
Assuming that a Nederlands postcode doesn't start with "0"
Otherwise /^[0-9]{4}[A-Z]{2}$/ 

 




You may read here for "Regular Expressions"
[url] manual.limesurvey.org/Using_regular_expressions [/url]

To add: the blank between digits and letters.

Or you can use an inputMask.
With the plugin "jquerySimpleMask"
[url] gitlab.com/SondagesPro/QuestionSettingsType/jquerySimpleMask [/url]
 


And there is another inputmask
Just enter this javascript snippet, that inserts this inputmask
[url] github.com/RobinHerbots/Inputmask [/url]
Code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/inputmask/4.0.9/jquery.inputmask.bundle.min.js"></script>
<script type="text/javascript" charset="utf-8">
    $(document).on('ready pjax:scriptcomplete',function(){ 
        $('#question{QID} input[type="text"]').inputmask({
            'mask': '9999 AA',
            'placeholder': '_',
            'removeMaskOnSubmit': false,
            'rightAlign': false,
        });
    });
</script>

Joffm

And to avoid holch's confusion.
Don't ask different things in one thread. Open a new one.

And a recommeandation: read the manual about question types.
[url] manual.limesurvey.org/Question_types [/url]


 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 2 years 10 months ago by Joffm.
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 10 months ago #216342 by holch

I'm trying to design a short free text question, only numbers can be entered in this answer box.

could I limit the correct answer format is four numbers and two letters?


I am confused. Is this another question or was the initial information "only numbers" wrong?

In any way, Joffm gave you a solution for this new requirement already.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose