- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput-password.html
More file actions
Latest commit
88 lines (81 loc) · 1.48 KB
/
Copy pathinput-password.html
File metadata and controls
88 lines (81 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<!DOCTYPE html>
<htmllang="en">
<head>
<metacharset="UTF-8">
<metaname="viewport" content="width=device-width, initial-scale=1.0">
<title>TRY</title>
</head>
<style>
div,
p {
padding:0;
margin:0;
}
.box {
width:241px;
height:40px;
border:1px solid #ccc;
box-sizing: border-box;
position: relative;
}
.mark {
position: absolute;
top:0;
left:0;
bottom:0;
right:0;
background-color:#fff0;
}
p {
border-right:1px solid #ccc;
float: left;
width:40px;
height:40px;
box-sizing: border-box;
}
input {
position: absolute;
top:0;
left:0;
background-color:#fff0;
border: none;
outline: none;
bottom:0;
right:0;
width:280px;
text-indent:15px;
letter-spacing:36px;
caret-color: transparent;
}
</style>
<body>
<divclass="box">
<p></p>
<p></p>
<p></p>
<p></p>
<p></p>
<inputtype="password" id="txt">
<divclass="mark" id="mark"></div>
</div>
</body>
</html>
<script>
vartxt=document.getElementById('txt');
varbut=document.getElementById('but');
varmark=document.getElementById('mark');
txt.oninput=function(e){
if(e.target.value.length===6){
txt.blur();
if(e.target.value!=='123123'){
console.log('fail');
}else{
console.log('success');
}
e.target.value='';
}
}
mark.onclick=function(e){
txt.focus();
}
</script>