-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
93 lines (82 loc) · 2.45 KB
/
index.html
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
89
90
91
92
93
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Messing with Paste</title>
<link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png">
<link rel="manifest" href="site.webmanifest">
<style>
* {
font-family: 'Helvetica Neue', 'Arial Nova', sans-serif;
}
body {
background-color: #f2f2f2;
}
.input-container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
}
.input-field {
display: flex;
flex-direction: row;
align-items: center;
margin: 10px;
}
label {
color: #333333;
width: 120px;
text-align: right;
padding-right: 15px;
}
input[type="text"] {
width: 200px;
height: 25px;
padding: 5px;
border: 1px solid #ccc;
border-radius: 5px;
}
</style>
</head>
<body>
<div class="input-container">
<div class="input-field">
<label for="field1">Regular</label>
<input type="text" id="field1" name="field1" placeholder="Pasting in here works">
</div>
<div class="input-field">
<label for="field2">No Paste</label>
<input type="text" id="field2" name="field2" onpaste="return false;" placeholder="Pasting in here will NOT work">
</div>
<div class="input-field">
<label for="field3">JS onpaste</label>
<input type="text" id="field3" name="field3" placeholder="Uses onpaste event handler">
</div>
<div class="input-field">
<label for="field4">JS eventlisten</label>
<input type="text" id="field4" name="field4" placeholder="Uses paste event listener">
</div>
</div>
<script>
// alternative using onpaste property
const field_3 = document.querySelector("#field3");
field_3.onpaste = (event) => {
console.log("running custom onpaste listener");
return false;
}
// alternative using addEventListener method
const field_4 = document.querySelector("#field4");
field_4.addEventListener("paste", (event) => {
console.log("running custom paste listener");
event.preventDefault();
return false;
});
</script>
</body>
</html>