I have short free text question that would like participants to choose one answer from dropdown list. But the problem is there maybe some people that put free text or other not in the list.
So, is there any solution to ..
Below is what I am using now.
$(document).ready(function() {
$('#question{QID} input[type="text"]').autocomplete({
minLength: 2,
source: ["Wayne Rooney","Ryan Giggs","David Beckham","Christiano Ronaldo","Adison Cavani"]
});
});
It's just super simple autocomplete I think as I have very small knowledge about these type of thing (coding) . So, if you can keeps it simple that will be super cool. I did googled some but doesn't work at all maybe because I don't understand it.
Thanks in advance for any helpers.
Justin
You can use the autocomplete "change" event - https://api.jqueryui.com/autocomplete/#event-change
$(document).ready(function() {
$('#question{QID} input[type="text"]').autocomplete({
minLength: 2,
source: ["Wayne Rooney","Ryan Giggs","David Beckham","Christiano Ronaldo","Adison Cavani"],
change: function( event, ui ) {
if (!ui.item) {
alert('Invalid answer');
$('#question{QID} input[type="text"]').val('');
}
}
});
});