Client script to make a field readonly based on choice fields with values yes and No

kavitha N
Tera Contributor

hi team,

i am facing issue with the client script below:

Based on choice field u_additional_peer_review_completed value as yes i need to make the u_additional_peer_review_date' as read only.

u_additional_peer_review_completed field have two choice field values yes ,no.

In the if condition if i am giving as yes  u_additional_peer_review_date this field is not coming as readonly.

Only for no and None u_additional_peer_review_date is displaying as readonly.

please let me know should i need to change anything in my code

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var additional_peer_item= g_form.getValue('u_additional_peer_review_completed');

if(additional_peer_item =='yes')
g_form.setReadonly('u_additional_peer_review_date',true);
else
g_form.setReadonly('u_additional_peer_review_date',false);

//Type appropriate comment here, and begin script below

}

1 REPLY 1

Community Alums
Not applicable
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    
    var additional_peer_item = g_form.getValue('u_additional_peer_review_completed');

    if (additional_peer_item === 'yes') {
        g_form.setReadonly('u_additional_peer_review_date', true);
    } else {
        g_form.setReadonly('u_additional_peer_review_date', false);
    }
    
    // You can add more code below if needed
}