Reputation: 41
I've searched quit a while on the internet but couldn't found what i wanted.
How to disable a text field when there is a select drop down selected with value (not emtpy)?
Also it would be nice to toggle it. When there is no option selected in the select drop down (no value) the user can type in the text field
I found something similar code but here it checks if the value is equal to "/\Custom\b/gi" I want that it checks on 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 advanced.
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>
Upvotes: 1
Views: 2231