<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>
</title>
<!--设置文本框的边框颜色和样式-->
<style type="text/css">
.input{
border-color:#FF0000;
border-style:solid;
}
</style>
<script type="text/javascript" language="javascript" >
<!--当文本框为空时,加载css的方法-->
function fun(test){
var value= document.getElementById(test).value;
var object= document.getElementById(test);
if(value==null||value==''){
object.setAttribute("className","input");<!--为文本框属性设值--!>
}else{ <!--className为返回当前对象的属性名--!>
abc.setAttribute("className","");
}
}
</script>
</head>
<body>
<input type="text" onBlur="fun('user_name')" id="user_name" >
</body>
</html>