<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style>
*{
padding: 0px;
margin: 0px auto;
}
.box{
width: 400px;
height: 120px;
}
.ipt{
position:fixed;
width: 200px;
height: 50px;
position: fixed;
border-radius: 5px;
margin: 50px 100px;
color: black;
font-size: 18px;
text-align: center;
}
.dian{
height: 25px;
width: 180px;
text-align: center;
background-color: aqua;
border-radius: 20px;
position: fixed;
margin: 15px 110px;
}
.wrong{
background-color: red;
}
.correct{
background-color: greenyellow;
}
</style>
</head>
<body>
<div class="box">
<input type="password" value="输入" class="ipt"/>
<p class="dian">请输入6~16字符的密码</p></div>
<script>
var ipt = document.querySelector('.ipt');
var btn = document.querySelector('.dian');
ipt.onblur = function(){
if(this.value.length<6 || this.value.length>16){
console.log('错误');
btn.className = 'dian wrong';
}else{
console.log('正确');
btn.className ='dian correct';
}
}
</script>
</div>
</body>
</html>
密码输入要求
于 2022-07-25 20:12:10 首次发布