It's all about the answers!

Ask a question

How to make read-only text field on the basis of condition

Sajjad Ali Khan (314152) | asked Aug 19 '15, 4:09 a.m.
 Hi All, 

I have a attribute which has two radio button "Yes" & "No" and the text field. 
Validation which i need to implement is if user click on "Yes" then text field become mandatory and if user click "No" then text field become read-only.

My script works fine if user click YES then text field become mandatory but if user click NO then text field doesn't become read-only.

Please help me to implement read-only part in following script:

(function() {
var WorkItemAttributes =;
dojo.declare("org.example.workitems.providers.RFCandEPMOReference1" , null, {
matches: function(workItem, configuration){
var rfc = workItem.getValue("ThisRFCisProject.attribute");
if(rfc == "enumeration.ThisRFCisProject.literal.l4"){
return true;
return false;

Accepted answer

permanent link
Donald Nong (14.5k614) | answered Aug 19 '15, 11:58 p.m.
You cannot do this in a validation script. You need to use a condition script to make it "dynamic read-only". See the "Dynamic read-only attributes with conditions" section in the below article for details.
Ralph Schoon selected this answer as the correct answer

Sajjad Ali Khan commented Aug 23 '15, 8:26 a.m. | edited Aug 23 '15, 8:54 p.m.

  Donald Nong yes you are right i'm not creating validation for above scenario, that why i have create a condition, could you please just incorporate Read-only part in above provided script ???

i hope you ave understand the issue which i have written above and my script is also working fine but i just need to incorporate read-only part within the same script.

Donald Nong commented Aug 23 '15, 8:57 p.m.

It appears that you did not completely understand what I meant. Let me put it this way, you will need two (not just one) scripts to achieve what you want - a "validation" script to make sure the attribute is mandatory, and a "condition" script to make sure the attribute is read-only. You cannot mix them together.

Sajjad Ali Khan commented Aug 24 '15, 4:59 a.m.

 Donald Nong Thanks brother for the clarification but how can i create the second script which will be used as condition for read-only part, could you please help me 

Donald Nong commented Aug 24 '15, 8:10 p.m.

An example was already given in my original answer.

See the "Dynamic read-only attributes with conditions" section in the below article for details.

Your answer

Register or to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.