http://jsfiddle.net/DKW7M/
HTML
<input type="text" id="test" />
JS:
$("#test").keyup(function() { var input = $(this); if( input.val() == "" ) { input.css( "border", "1px solid #000" ); } });
I changed it to black to make it easier to see.
If you want to do this for multiple identifiers, try:
<form id="some_form"> <input type="text" /> <input type="text" /> </form>
$("#some_form input").each(function() { $(this).keyup(function() { var input = $(this); if( input.val() == "" ) { input.css( "border", "1px solid #000" ); } }); });
user1508519
source share