<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
span{
width: 14px;
height: 15px;
display: inline-block;
}
.right{
background-image: url("../Resources/imgs/right.png");
}
.error{
background-image: url("../Resources/imgs/error.png");
}
</style>
</head>
<body>
<input type="text">
<span class=""></span>
<script>
document.body.firstElementChild.oninput = function (){
this.nextElementSibling.className = (/^(\w|-){6,16}$/.test(this.value)) ? "right" : "error";
}
</script>
</body>
</html>
验证用户信息是否有效
最新推荐文章于 2024-07-15 13:17:25 发布