Using Custom Logic in Forms

I came across a requirement where if a field has value already present, it needs to be disabled.
I’m not able to find the documentation for using conditional and logic, please suggest some sources.

I tried to use Logic with javascript trigger but I’m not sure when this trigger is evaluated, when the form loads? or the component loads?
The action part is executed even if I just write return true; inside the trigger. What exactly we need to be added here?

I don’t know much about javascript but I tried a few ways to use instance.disabled but its not working.

Thanks for the help.

I have updated the Action javascript to :
if(value.length > 0)
component.disabled = true;

And it seems to be working, but the trigger runs even on single key press in text box and disables it.