- Posts: 18
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
var thisInput = $('input.text', thisQuestion);
var thisInput = $('textarea', thisQuestion);
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify this question var thisQuestion = $('#question{QID}'); // Define the disallowed strings and allert text var disallowed = ['refused', 'none of your business', 'nunya']; var alertText = 'You have entered an invalid string!'; // Interrupt the Next/Submit click $('#movenextbtn, #movesubmitbtn').bind('click', function () { var thisInput = $('textarea', thisQuestion); var thisVal = thisInput.val(); thisInput.removeClass('disallowed-string'); // Loop through all disallowed strings $(disallowed).each(function(i) { // If disallowed string found in input value if(new RegExp('\\b'+this+'\\b', 'i').test(thisVal) == true) { thisInput.addClass('disallowed-string'); // Add a class alert(alertText); // Pop up alert return false; // Exit the loop } }); // Abort the Next/Submit if we found a disallowed string if(thisInput.hasClass('disallowed-string')) { return false; } }); }); </script>
<link href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" rel="stylesheet" /><script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script><script type="text/javascript" charset="utf-8"> $(document).ready(function() { $('#question{QID} input[type="text"]').autocomplete({ minLength: 2, // This line is optional, signifies number of keystrokes before autocomplete is initiated source: ["Organisation A", "Organisation B", "Organisation C"] }); }); </script>
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { $('#question{QID} input[type="text"]').autocomplete({ minLength: 2, source: ["Test1","Test2","Test3","Afghanistan", "Ägypten", "Albanien", "Algerien", "Andorra", "Angola", "Antigua und Barbuda", "Äquatorialguinea", "Argentinien", "Armenien", "Aserbaidschan", "Äthiopien", "Australien", "Bahamas", "Bahrain", "Bangladesch", "Barbados", "Belgien", "Belize", "Benin", "Bergkarabach", "Bhutan", "Bolivien", "Bosnien und Herzegowina", "Botswana", "Brasilien", "Brunei", "Bulgarien", "Burkina Faso", "Burundi", "Chile", "Volksrepublik China", "Cookinseln", "Costa Rica", "Dänemark", "Deutschland", "Dominica", "Dominikanische Republik", "Dschibuti", "Ecuador", "El Salvador", "Elfenbeinküste", "Eritrea", "Estland", "Fidschi", "Finnland", "Frankreich", "Gabun", "Gambia", "Georgien", "Ghana", "Grenada", "Griechenland", "Guatemala", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Honduras", "Indien", "Indonesien", "Irak", "Iran", "Irland", "Island", "Israel", "Italien", "Jamaika", "Japan", "Jemen", "Jordanien", "Kambodscha", "Kamerun", "Kanada", "Kap Verde", "Kasachstan", "Katar", "Kenia", "Kirgisistan", "Kiribati", "Kolumbien", "Komoren", "Kongo, Demokratische Republik", "Kongo, Republik", "Korea, Nord", "Korea, Süd", "Kosovo", "Kuba", "Kuwait", "Laos", "Lesotho", "Lettland", "Libanon", "Liberia", "Libyen", "Liechtenstein", "Luxemburg", "Madagaskar", "Malawi", "Malaysia", "Malediven", "Mali", "Malta", "Marokko", "Marshallinseln", "Mauretanien", "Mauritius", "Mazedonien", "Mexiko", "Mikronesien", "Moldawien", "Monaco", "Mongolei", "Montenegro", "Mosambik", "Myanmar", "Namibia", "Nauru", "Nepal", "Neuseeland", "Nicaragua", "Königreich der Niederlande", "Niger", "Nigeria", "Niue", "Nordzypern", "Norwegen", "Oman", "Österreich", "Osttimor / Timor-Leste", "Pakistan", "Palästina", "Palau", "Panama", "Papua-Neuguinea", "Paraguay", "Peru", "Philippinen", "Polen", "Portugal", "Ruanda", "Rumänien", "Russland", "Salomonen", "Sambia", "Samoa", "San Marino", "São Tomé und Príncipe", "Saudi-Arabien", "Schweden", "Schweiz", "Senegal", "Serbien", "Seychellen", "Sierra Leone", "Simbabwe", "Singapur", "Slowakei", "Somalia", "Somaliland", "Spanien", "Sri Lanka", "St. Kitts und Nevis", "St. Lucia", "St. Vincent und die Grenadinen", "Südafrika", "Sudan", "Südossetien", "Südsudan", "Suriname", "Swasiland", "Syrien", "Tadschikistan", "Taiwan", "Tansania", "Thailand", "Togo", "Tonga", "Transnistrien", "Trinidad und Tobago", "Tschad", "Tschechien", "Tunesien", "Türkei", "Turkmenistan", "Tuvalu", "Uganda", "Ukraine", "Ungarn", "Uruguay", "Usbekistan", "Vanuatu", "Vatikanstadt", "Venezuela", "Vereinigte Arabische Emirate", "Vereinigte Staaten", "Vereinigtes Königreich", "Vietnam", "Weißrussland", "Westsahara", "Zentralafrikanische Republik", "Zypern"] }); }); </script>
gitlab.com/SondagesPro/QuestionSettingsType/autoComplete
But must be updated to allow search and disable other choice.
Need to use onInavlidSelection : github.com/devbridge/jQuery-Autocomplete...tings-local-and-ajax