Welcome to the LimeSurvey Community Forum

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

Validate text answer against a list of words

More
4 years 6 months ago #189811 by BusyBonsai
Replied by BusyBonsai on topic Validate text answer against a list of words
Dear DenisChenu
Yeah, sorry I didn't mention it earlier: I use LimeSurvey Version 2.73.0+171219 for this.

We are planning to jump to a newer version "soon". We haven't decided yet whether that will be Version 3.8.0+180522 or even 4.x .

Best
Adam
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 6 months ago #189816 by DenisChenu
Replied by DenisChenu on topic Validate text answer against a list of words
Don't update to 4.X : this version is NOT READY for production … think best is to update to current 3 and stay in 3 since it bevome an LTS.

Else : maybe try with this version
gitlab.com/SondagesPro/QuestionSettingsT...5c9f889531eed437ee7b
It was done in 2.73.

But like i already say : it don't give you the exact need because it's not done for this .

The plugin have 2 utilities
1. And autocomplete helper on free text, but allow other text to be entered
2. Dropdown style

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
More
4 years 6 months ago #189819 by BusyBonsai
Replied by BusyBonsai on topic Validate text answer against a list of words
But I can tweak what you give me with this ( github.com/devbridge/jQuery-Autocomplete...tings-local-and-ajax ) so it gives me my exact need, right?

Else : maybe try with this version
gitlab.com/SondagesPro/QuestionSettingsT...5c9f889531eed437ee7b
It was done in 2.73.


Thanks so far - I will follow up on this next week! Till then, have a nice weekend! And thanks for the version 3.x vs 4.x advice!
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 6 months ago #189825 by DenisChenu
Replied by DenisChenu on topic Validate text answer against a list of words

BusyBonsai wrote: But I can tweak what you give me with this ( github.com/devbridge/jQuery-Autocomplete...tings-local-and-ajax ) so it gives me my exact need, right?

Maybe ;)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
More
4 years 6 months ago #190262 by BusyBonsai
Replied by BusyBonsai on topic Validate text answer against a list of words
So I / we couldn't get the hang of it with any plug-ins. But the following code meets our needs:
Code:
<script>
$(document).ready(function() {
 
    var qID = {QID};
 
    var orgs = ["Hello World", "Test"]
 
var currentVal = $('input.text', '#question' + qID).val();  
 
    $('#question'+qID+' input[type="text"]').autocomplete({
        minLength: 2, 
        source: orgs,
        change: function(event, ui) {
          if(!ui.item){ // Nothing matched in the data array so clear the value
            $(this).val('');
          }
          currentVal = $(this).val();
      },
        response: function(event, ui) {
          if($(ui.content).length == 0){ // Nothing found in the data array so revert to last value
            $(this).val(currentVal);
                                                alert("Koala");
            setTimeout(function() {
              if(currentVal != '') {
                $('input.text', '#question' + qID).autocomplete('search');
              }
            }, 200);
          }
          else {
            currentVal = $(this).val();
          }
        }
      }).on('keyup', function(e) {
        if($.trim($(this).val()) == '') {
          $(this).val('');
          currentVal = $(this).val();
        }
      }); 
  });
</script>
<style type="text/css">.form-horizontal .control-label {
    margin-bottom: 0;
    padding-top: 11px;
    text-align: left;
}
  .ui-autocomplete {
    width: 400px !important;
  }
</style>

In case anyone else was looking for this and wants to reuse; you probably wanna delete the "alert("Koala");" line. Our Client just wanted an error message to appear in some cases.

Thanks for everyone's patience :)
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose