密码匹配失去焦点文本框外框改变颜色
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<input type="text" value="请输入密码" id="text"/>
<script>
//获取文本框
document.getElementById("text").onblur=function () {
//判断密码的长度
if(this.value.length>=6&&this.value.length<=10){
this.style.border="1px solid #00ff00";
}else{
this.style.border="1px solid #ff5000";
}
};
</script>
</body>
</html>
来源:CSDN
作者:黎犁泥栗
链接:https://blog.csdn.net/qq_43618136/article/details/104253779