Example code that does not work:
var empty = "";
if(this.getField("Example") == empty)
I don't see an immediate problem with your code. Of course, writing the code is only half the story; you also have to decide which event to attach it to. What happens when you try to use it. and what does it say in the console?