fix: accept any option starting with 'other'

See #75
This commit is contained in:
James Graham
2021-02-15 19:13:14 +00:00
parent a6e8f06441
commit 9be49f4faf

View File

@@ -55,14 +55,14 @@
function hasOption(select, option) {
var exists = false;
for (var i = 0; i < select.options.length; i++) {
if (select.options[i].text === option) return true;
if (select.options[i].text.toLowerCase().startsWith(option)) return true;
}
return false;
}
function setFreeTextState(select, freeTextField) {
if (select.selectedOptions[0].text === 'Other') {
if (select.selectedOptions[0].text.toLowerCase().startsWith('other')) {
freeTextField.show();
} else {
freeTextField.hide();
@@ -71,7 +71,7 @@
$(document).ready(function(){
$('select').each(function(index, element) {
if (hasOption(element, 'Other')) {
if (hasOption(element, 'other')) {
var freeTextField = $('#' + element.id + '_free').parent();
setFreeTextState(element, freeTextField);