<script type="text/javascript">
/* function showTips() {
document.getElementById("userspan").innerHTML="<font color='navy'>用户名必填!</font>";
}
function checkUser() {
//获取用户输入的用户名
var uValue = document.getElementById("user").value;
//进行校验
if(uValue=="") {
document.getElementById("userspan").innerHTML="<font color='red'>用户名不能为空!</font>";
} else {
document.getElementById("userspan").innerHTML="";
}
} */
function showTips(id,info) {
document.getElementById(id+"span").innerHTML="<font color='navy'>"+info+"</font>";
}
function check(id,info) {
//获取用户输入的用户名
var value = document.getElementById(id).value;
//进行校验
if(value=="") {
document.getElementById(id+"span").innerHTML="<font color='red'>"+info+"</font>";
} else {
document.getElementById(id+"span").innerHTML="";
}
}
</script>
<tr>
<td>
用户名
</td>
<td>
<input onblur="check('user','用户名不能为空!')" onfocus="showTips('user','用户名必填!')" type="text" name="user" size="34px" id="user"/>
<span id="userspan"></span>
</td>
</tr>
<tr>
<td>
密码
</td>
<td>
<input onblur="check('password','密码不能为空!')" onfocus="showTips('password','密码必填!')" type="password" name="password" id="password" size="34px"/>
<span id="passwordspan"></span>
</td>
</tr>