How do I set a Radio Button to be required using JavaScript and also put it back to not required?
Q3 - is a dropdown list with the following values ('New', 'Trial', 'Update', 'Remove')
Q8 - is a radio button ('yes', 'no')
$('#q3 select').change(function () {
var s = $('select[id^="Field3"]').val()
if ((s === 'Update') || (s === 'Remove')) {
//Make it a required field
$('#q8 label').append('<span class="cf-required">*</span>');
$('#q8 input').attr('required', 'True');
} else {
//Change to not a required field
$('#q8 span.cf-required').remove();
$('#q8 input').removeClass('required').removeAttr('required');
}
})
Two issues with the code:
1) When the drop down is changed to 'Update' or 'Retire' the Radio button label and the Yes & No buttons all become required. A state that can not exist.
2) The required field on the Yes and No looks like this required="required" not like this required="True".
So when the dropdown list is 'Update' or 'Retire' the radio button looks like: