Is it possible to deactivate a selected option in a radio button group if a text field is filled out instead?
To deactivate a selected option in a radio button group if a text field is filled out instead, you can use JavaScript to dynamically disable the radio button when the text field is not empty. You can achieve this by adding an event listener to the text field that checks its value and disables the radio button accordingly.
<script>
document.addEventListener('DOMContentLoaded', function() {
const textField = document.getElementById('text-field');
const radioBtn = document.getElementById('radio-btn');
textField.addEventListener('input', function() {
if (textField.value !== '') {
radioBtn.disabled = true;
} else {
radioBtn.disabled = false;
}
});
});
</script>