The css is easy:
input.wrong {
border:1px solid #900;
font-color:#900;
}
The PHP just needs to take the validation and add the class "wrong" to the proper input. So something like:
if(!isset($_POST['username']) || empty($_POST['username']) || eregi('/[^a-z0-9_.-]/', $_POST['username']))
echo '<input type="text" name="username" class="wrong" />';
That's an oversimplified example, but that's what you'd do. Or something similar.