console
$("#login").click(function(){
if($(":text").val().length ==0 )
{$("#firstname").focus();
alert("请填写账号密码");}
else if($(":password").val().length ==0 )
{$("#password").focus();
alert("请填写密码");}
});
$("input").keydown(function(){
$("input").css("background-color","red");
});
$("input").keyup(function(){
$("input").css("background-color","gray");
});
<table border="0" style="width:100% ; height:100% text-align: center;">
<tr>
<td colspan="2" style="background-color:;text-align: center;">
<h1>
用户登录
</h1>
<SPAN style="float:right">
<a href="http://jsrun.net/8tkKp/show" target='blank'>
洛阳高校新闻网
</a>
</SPAN>
</td>
</tr>
<td style="background-color:;text-align: center;">
<h4>
账号:
<input id="firstname" type="text" name="firstname">
<br>
密码:
<input id="password" type="password" name="pwd">
<br>
<button id="login">
登录
</button>
<button >
<a href="http://jsrun.net/zMkKp/show" target="blank">注册</a>
</button>
</h4>
</td>
<tr>
<td colspan="2" style="background-color:;text-align:center;">
</td>
</tr>
</table>
a{text-decoration:none}