You can color the background with the background-color CSS property.
For changing based upon whether the field is empty or not, you will need to establish event handlers on the text field to detect changes. The onchange handler itself will not be enough because it's not called on individual keystrokes. You'll need to also at least listen to onkeyup.
It's not foolproof however. I'm not sure how you can capture the field being emptied by a cut operation via the menu for example.
[ October 03, 2005: Message edited by: Bear Bibeault ] [ October 03, 2005: Message edited by: Bear Bibeault ]