<html>
<head>
<title>home.html</title>
</head>
<script type="text/javascript">
function $(id){
return document.getElementById(id);
}
function hidElement(id){
$(id).style.display = "none";
}
function showElement(id){
$(id).style.display = "block";
}
function checkName(value){
if (value == "") {
showElement("span1");
$("span1").innerHTML="用户名不能为空";
}
else {
hidElement("span1");
}
}
function keydown(){
hidElement("span1");
}
</script>
<style type="text/css">
#span1 {
display: none;
color: red;
}
</style>
<body>
<div id="div1" class="myDiv">
<form method="post" action="" οnsubmit="">
用户名:<input type="text" name="uName" id="uName" onBlur="checkName(this.value)"; οnkeydοwn="keydown()"/><span id="span1"></span>
</form>
</div>
</body>
</html>
<head>
<title>home.html</title>
</head>
<script type="text/javascript">
function $(id){
return document.getElementById(id);
}
function hidElement(id){
$(id).style.display = "none";
}
function showElement(id){
$(id).style.display = "block";
}
function checkName(value){
if (value == "") {
showElement("span1");
$("span1").innerHTML="用户名不能为空";
}
else {
hidElement("span1");
}
}
function keydown(){
hidElement("span1");
}
</script>
<style type="text/css">
#span1 {
display: none;
color: red;
}
</style>
<body>
<div id="div1" class="myDiv">
<form method="post" action="" οnsubmit="">
用户名:<input type="text" name="uName" id="uName" onBlur="checkName(this.value)"; οnkeydοwn="keydown()"/><span id="span1"></span>
</form>
</div>
</body>
</html>