is there a way to check the input of a "short free text" element against a list/array of values?
I have a list of approximately 1000 strings and I cant do this with a dropdown menu, because it would be to much scrolling. So I have this script which uses the given input and makes suggestions to the user, like the google search bar. The problem with this solution is, that the user can upload the answer incomplete. Thats why I need to validate that the list given contains the exact string given by the user. Is this somehow possible with the built-in limesurvey features?
Thank you for your solution. I was using a script like this already, but it tranferred the content of the form anyway. Didnt matter if my check returned true or false.
Solution is pretty straightforward in my case: i forgot to add a "return" to the function call. Like this: onsubmit="return checkInput(this)"
Since I added the return, everything works fine.
Thanks for your help.
Today I encountered a new issue with the autocomplete script from
jqueryui.com/autocomplete/
I added the text field to a condition for another question. If a certain string is entered a new questions appears. If I scroll through the suggestions provided by the script with the arrow keys and i hit a string out of the conditions the new question appears. Same thing if I enter the string completely manually. BUT if i click a matching string, the input doesn't seem to refresh and the additional question does not appear! If I clicked the string and press an arrow key (on a pc keyboard) the input is accepted/refreshed and the question appears.
Because the survey will be carried out using mobile phones the only way a string will be selected is by "clicking" it, so I really need this to work. Does anybody know a workaround for this? :dry:
It sounds like you will need to put a listener on the autocomplete (probably with the
select event
) that would fire the checkconditions() function on the text input.
Cheers,
Tony Partner Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Sorry my javascript is pretty basic, what would I add in for the .autocomplete({ select: ... }); ?
Do I add the the autocompleteselect event to both functions? Like this:
Since you are initializing the autocomplete, it's better to do it there. Something like this (untested):
Code:
$('#question{QID}').autocomplete({
// Some autocomplete options go here...
// Fire the checkconditions function
select: function(event, ui) {
var thisInput = $('#question{QID} input.text');
checkconditions($(thisInput).attr('value'), $(thisInput).attr('name'), 'text');
}
});
Cheers,
Tony Partner Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.