Interesting case... If the property is empty, then the user can enter something. But as soon as the user has written something in the dialog, the textbox should be disabled.
How does the user change the values if it is wrong or needs to be changed?
But to answer your question. You use the dialogue listeners. An example, that is used a lot in this forum, is to look at /libs/foundation/components/list/dialog/items/list/items/listFrom/listeners and figure out how that works. This is a part of the Widget configuration and can be found at [1]. What you are trying to do is a Toggle.
/Ove
[1] http://dev.day.com/docs/en/cq/current/developing/widgets.html