I am trying to set a field to change the Employee ID field (.empID) to not be required if the radio button "New Hire" is selected on the Requested Action field (.action). I have that working, but when I select a different radio button the Employee ID field stays not required. I would want it to change back to required whenever "New Hire" is not selected on the Required Action field. Can someone please help me with the JavaScript I have?
$(document).ready(function() {
/* This sets the Employee ID field to required using javascript */
$('.empID label').append('<span class="cf-required">*</span>');
$('.empID input').attr('required','True');
/* This removes the required class and asterisk from the Employee ID field
when the New Hire is selected, allowing the form to submit */
$('.action input').change(function () {
if ($('.action input[value="New Hire"]:checked').length > 0)
$('.empID span.cf-required').remove();
$('.empID input').removeClass('required').removeAttr('required');
});
});