Currently, I am developing a simple functionality for radio buttons that activates an input text box when clicked. If any other radio button is selected, the input field should go back to its disabled state.
Initially, everything was working smoothly until I tried to include the ID element as a parameter. At this point, I ended up using a CSS selector :not to exclude all other radio buttons.
'input[type=radio]:not(element)'
I am now seeking a jQuery solution to replace this problematic line of code. Can you suggest an alternative approach?
function enableInputonClick(element) {
var input = $('.form-control-optional');
$(element).on('ifClicked', function() {
if(input.length && input.attr("disabled", "disabled")) {
input.removeAttr("disabled");
}
});
$('input[type=radio]:not(element)').on('ifClicked', function() {
if(input.length && input.attr("disabled", "")) {
input.attr("disabled");
}
});
}
enableInputonClick("#myRadioEl");