Hi Haritha,
If you are still looking for solution, please find the below code for reference and add it into your basic form(entity form) under(Additonal settings tab) as custom javascript:
$(document).ready(function() {
// Add event validator
if (typeof(Page_Validators) == 'undefined') return;
// Create new validator
var newValidator = document.createElement('span');
newValidator.style.display = "none";
newValidator.id = "new_dateofdischargeValidator";
newValidator.controltovalidate = "new_dateofdischarge";
newValidator.errormessage = "<a href='#new_dateofdischarge_label'>Date is a required field.</a>";
newValidator.evaluationfunction = function() {
if (!$('#new_previouspicuadmissionfortoday_0').is(':checked') && $('#new_previouspicuadmissionfortoday_1').is(':checked')) {
if ($('#new_dateofdischarge').val() == "") {
return false;
} else {
return true;
}
} else {
return true;
}
};
Page_Validators.push(newValidator);
// Add validator element
$("#new_previouspicuadmissionfortoday_0").change(function() {
if (this.checked) {
$("#new_dateofdischarge").attr('aria-required', "false");
$('#new_dateofdischarge').parent().prev().removeClass("required");
}
});
$("#new_previouspicuadmissionfortoday_1").change(function() {
if (this.checked) {
$("#new_dateofdischarge").attr('aria-required', "true");
$('#new_dateofdischarge').parent().prev().addClass("required");
}
});
})
If selected value is set to “No” then date field is set to not required as shown below:
If selected value is “Yes” date field is set to be required as shown below:
Hope this helps.
Thanks!