Make field Readonly -Onload

ch_karthikeya
Tera Contributor

when form is Loaded -if User name( value :User)   is Empty then Devision field should be Readonly

find_real_file.png

var gd=g_form.getDisplayValue('User');

if(gd== "   ")  

{

g_form.setReadOnly('devision',true);

}

}

it is not working as per my expectation

1 ACCEPTED SOLUTION

Simon Christens
Kilo Sage

Try



var gd=g_form.getValue('User');


if(gd== "")


{


g_form.setReadOnly('devision',true);


}


}


View solution in original post

8 REPLIES 8

Mihir Mohanta
Kilo Sage

Try this



var gd=g_form.getValue('User');


if(gd== "")


{


g_form.setReadOnly('devision',true);


}


}


Dubz
Mega Sage

You can do this with a UI policy. eg:



find_real_file.png



Don't use client script unless you have to.


Jitu Sharma
Tera Contributor

You can also try this.



var gd=g_form.getDisplayValue('User');


if(!gd)


g_form.setReadOnly('devision',true);




---------------------


In your code


var gd=g_form.getDisplayValue('User');


if(gd== "   ") // you used white space for validating Nan Values


{


g_form.setReadOnly('devision',true);


}


}


Vishal Khandve
Kilo Sage

Hi Karthikeya,


You can achieve this by simply using UI Policy


use the condition: user name is empty



Thank you,


vishu