I have been searching for a while on the internet but I couldn't find what I was looking for.
How can I disable a text field when a select drop down is selected with a value (not empty)?
It would also be nice to toggle it. When there is no option selected in the select drop down (no value), the user should be able to type in the text field.
I came across some similar code, but it checks if the value is equal to "/\Custom\b/gi". I want it to check if something is selected or not.
$('#Select_Font, #Enter_Text').attr('disabled', 'disabled');
$('.dropdownstyle').change(function () {
var present = $(this).val().match(/\Custom\b/gi) == null ? true : false;
if(present){
$('#Select_Font, #Enter_Text').attr('disabled', 'disabled');
}
else{
$('#Select_Font, #Enter_Text').removeAttr('disabled');
}
});
Source: How to enable or disable drop-down or text-box on selection other drop-down?
Is that possible? Thanks in advance.
Edit:
HTML
<div class='row'>
<div class="large-6 columns">
<label for="group">Group
<select name="selectGroup" id="selectGroup">
<option value="">Choose a group</option>
<?php
while ($row = $result->fetch_assoc()) {
echo '<option value="' . $row['group'] . '">' . $row['group'] . '</option>';
}
?>
</select>
</label>
</div>
<div class="large-6 columns">
<label for="group">Or make a new group
<input type="text" name="makeGroup" id="makeGroup"/>
</label>
</div>
</div>