代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<input type="text"id="user">
<script>
document.getElementById("user").onblur=function (anyparameter) {
if(this.value==""){
alert("输入为空!");
}
}
</script>
</body>
</html>
运行结果: