function message(){
alert("请确定已输入密码后,在移开!"); }
</script>
</head>
<body>
<form>
用户:<input name="username" type="text" value="请输入用户名!" ">
密码:<input name="password" type="text" value="请输入密码!" onblur="message()">
</form>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>xxx</title>
<script>
function message(el) {
console.log(el);
if(!el.value && el.value !== 0){
alert("请确定已输入密码后,在移开!");
}
}
</script>
</head>
<body>
<form>
用户:<input name="username" type="text" placeholder="请输入用户名">
密码:<input name="password" type="password" placeholder="请输入密码!" onblur="message(this)">
</form>
</body>
</html>你可以这样试一下