When an input is empty I want it to have a red outline (so users know that he missed the field).
When the input is not empty – there should be no outline at all.
The problem is, the outline appears only after I leave the input empty and click somewhere else.
Just try to erase #input and don’t click.
Changing live() to blur() doesn’t help.
Any ideas?
You should use the
keyupwhich indicates a key press that checks the input field every time you press a key.Working demo.
More information on keyboard events: